Angular FAQ: Top Questions
26. What is change detection in Angular?
Change detection is the mechanism by which Angular determines what has changed in the model and updates the view accordingly. It checks component state and updates the DOM automatically if changes are detected.
- Default strategy: Angular checks the entire component tree when an event is triggered.
- OnPush strategy: Angular checks only when input-bound properties change.
@Component({
selector: 'app-sample',
changeDetection: ChangeDetectionStrategy.OnPush,
...
})