Reputation: 292
How angular2 perform change detection default strategy ? I have gone through some post related with the change detection and got some details like 'angular2 creates change detector for every component'.
Now for instance If I've 4 components (comp1, comp2 comp3 & comp4) and I change comp4 property so change detection would be perform through all components or single component ?
Can you please provide some code tutorial link related above info ?
Upvotes: 3
Views: 152
Reputation: 105547
Here is the detailed article that will help you understand change detection:
Also see this answer.
Now for instance If I've 4 components (comp1, comp2 comp3 & comp4) and I change comp4 property so change detection would be perform through all components or single component ?
If you change the comp4
property as a result of some async opertation like setTimeout
, the change detection will run from root level component and down to children. So you will have change detection for all components.
If some of the components set ChangeDetectionStrategy.OnPush
, they will be skipped if the input bindings haven't changed.
Upvotes: 1