From these two posts:
- The mechanics of DOM updates in Angular
- Angular 2 Performance: Is it better to bind with a data member than a function?
I understand how the DOM updated when the 'Change Detection' has occurred. The thing I do not understand from "Everything you need to know about change detection in Angular" is how Angular keeps track of what properties have beed used inside the function and therefore when it should run the 'Change Detection'.
Let's assume this is the parent Component view.
<child [prop]="func()"></child>
where func()
is
func() { return this.parentProp }
and parentProp
has not been used in the template. If and when parentProp
gets changed by a service, how does the Angular knows that func()
depends on parentProp
and therefore should trigger a 'Change Detection' and update the view.