ComponentRef setInputs support

This issue has been tracked since 2022-09-21.

Which @angular/* package(s) are relevant/related to the feature request?

@angular/core

Description

Hi! angular team!

In the last angular release you added a new method to the ComponentRef called "SetInput" that allows to change one input property of the component.

This new feature works well, but when we need to update more than one input "at the same time" the ngOnChanges is executed multiple times (one for each property updated).

Proposed solution

I propose to change the method input in order to allow a Record (where the key is the name of the property) and of course rename the method to "setInputs".

Alternatives considered

No alternatives for now.

angular-robot[bot] wrote this answer on 2022-09-23

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

pkozlowski-opensource wrote this answer on 2022-09-28

This feature requests is build on the assumptions that doesn't hold true.

This new feature works well, but when we need to update more than one input "at the same time" the ngOnChanges is executed multiple times (one for each property updated).

This is not what happens - you can set as many inputs (via setInput) as many times as you need. The ngOnChanges hook runs only once when change detection runs, see:
https://stackblitz.com/edit/angular-standalone-zlpq7n?file=src%2Fmain.ts

I'm going to mark this as "needs reproduction" since the current behaviour of the framework seems to be expected and correct.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-10-05
Star Count 84147
Watcher Count 3063
Fork Count 22247
Issue Count 1201

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date