Change detection 是 Angular 保持 DOM 与组件数据同步的方式 — 在任何可能改变状态的事件之后,它检查组件并在数据改变的地方更新视图。默认情况下这种检查范围很广;OnPush 为性能而缩小检查范围。
默认变更检测如何工作
text
An async event fires (click, HTTP response, setTimeout) →
Zone.js notifies Angular → Angular checks the ENTIRE component tree
top-to-bottom → updates any bindings whose values changed.
默认情况下( 策略),Angular 在每个事件上都重新检查 — 正确,但在大型树中可能浪费资源。
