Change Detection and the OnPush Strategy
Learn Change Detection and the OnPush Strategy (Phase 10 · Advanced Angular (Essential), Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
How Angular knows when to update the view • Change detection (CD) compares template bindings with their previous values and updates the DOM. By default zone.js patches async APIs (events, timers, HTTP) and triggers a CD pass over the whole component tree after each. • The Default strategy checks every component every time: simple but can be slow in big apps. Template expressions run on each pass, so they must be cheap. • Use ng.profiler /Angular DevTools to see how often components are checked.