Thursday, December 28, 2017

How do I tell if a particular Input has changed at ngOnChanges at an Angular 4 component?

Great question! I recommend making a private sister variable for the Input variable and setting the private variable equal to the Input variable at ngOnInit. Then at ngOnChanges compare the two for a discrepancy. If there is a discrepancy then it is time to act and in acting you will also want to assign the Input's value to the private sister's value again.

No comments:

Post a Comment