Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular – Change Detection triggered when Strategy OnPush

I’m triggering tick() and detectChanges() in the root component. In root component I have one child with onPush strategy, which logically means it shouldn’t triger that child component if data has not changed.

Really small example about this issue:
https://github.com/michalgrzegorczyk-dev/change-detection

Why ChildWrapperComponent runs ngDoCheck() in this case? It’s OnPush! Why?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

NgZone is disabled. The reset of the components works as expected, only root components are triggerend even it’s OnPush.

>Solution :

When you run detectChanges() manually, the component itself and all the children will be checked for changes.

Docs: detectChanges()

Checks this view and its children. Use in combination with detach to
implement local change detection checks.

Angular|Detect Changes

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading