You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: add method to change inputs in ComponentRef #22567
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
To change inputs of component creates via ComponentFactory we need to access component instance directly, like that:
componentRef.instance.myInput='new value';
Expected behavior
There should exist a method on ComponentFactory that changes inputs, for example:
Minimal reproduction of the problem with instructions
N/A
What is the motivation / use case for changing the behavior?
Changing properties on component instance won't call ngOnChanges. You have to do it manually, and that's really annoying because You really can't assume that it's not necessary for component to work correctly.
Calling changeInputs should also call ngOnChanges on component instance. It's also might be a good idea to delay it until change detection is triggered or trigger change detection automatically when changeInputs is called, so ngOnChanges would be called only once before ngDoCheck. Again, some components may rely on ngOnChanges being followed by ngDoCheck.
This is a very cool idea. It should also allow to test OnPush components without adding a wrapper component, so should at least partially resolve #12313.
Activity
devoto13 commentedon Mar 3, 2018
This is a very cool idea. It should also allow to test OnPush components without adding a wrapper component, so should at least partially resolve #12313.
angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
vzakharov-rxnt commentedon May 3, 2022
Is it still being considered? I think it would be a very useful feature.
angular-automatic-lock-bot commentedon Aug 1, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.