-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Feature: add method to change inputs in ComponentRef #22567
Copy link
Copy link
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: change detectioncore: dynamic view creationcore: inputs / outputsfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration
Milestone
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: change detectioncore: dynamic view creationcore: inputs / outputsfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration
I'm submitting a...
Current behavior
To change inputs of component creates via ComponentFactory we need to access component instance directly, like that:
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.