What is the OnPush change detection strategy?
Model answer
With ChangeDetectionStrategy.OnPush, a component is checked only when one of its inputs changes by reference, an event happens in the component or its template, an async pipe emits, a signal it reads changes, or you mark it for check. It skips the rest.
It reduces work in large apps, but you must treat data as immutable: replace objects and arrays instead of changing them in place, otherwise the view will not update.
Tips
- Mention immutability.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.