Can you programatically trigger angular\'s change detection when mutating a component property in angular2?
@Compon
The reason it doesn’t work can be found in the source code.
https://github.com/angular/angular/blob/885f1af509eb7d9ee049349a2fe5565282fbfefb/packages/core/src/view/provider.ts
Where ngOnChanges is called from, and where the SimpleChanges structure is built are very much tied into the component / directive code.
It’s not just a ‘change tracker’ running that looks over every property however it was set, so ngOnChanges only works for bindings set by parent components.
This is where ngDoCheck comes in and possibly KeyValueDiffers.
See also:
https://netbasal.com/angular-the-ngstyle-directive-under-the-hood-2ed720fb9b61 https://juristr.com/blog/2016/04/angular2-change-detection/