Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 change detection with CD class

Tags:

angular

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 ?

like image 585
shubham AK Avatar asked Mar 24 '26 17:03

shubham AK


1 Answers

Here is the detailed article that will help you understand change detection:

  • Angular’s $digest is reborn in the newer version of Angular
  • Everything you need to know about change detection in Angular

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.

like image 198
Max Koretskyi Avatar answered Mar 27 '26 11:03

Max Koretskyi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!