Think about what Zone.js wraps to know when to update the UI.
Zone.js patches asynchronous APIs like setTimeout, promises, and DOM events. When these complete, Angular runs change detection automatically.
Consider what 'outside Angular's zone' means for automatic updates.
Running code outside Angular's zone means Zone.js does not track those async events, so Angular won't trigger change detection automatically.
import { Component, NgZone } from '@angular/core'; @Component({ selector: 'app-root', template: '' }) export class AppComponent { constructor(private ngZone: NgZone) {} runTask() { // Which option below correctly runs outside Angular's zone? } }
Look for the method that explicitly runs code outside Angular's zone.
NgZone's runOutsideAngular() method runs the callback outside Angular's zone, preventing automatic change detection.
Think about what happens when you run code outside Angular's zone.
Running code outside Angular's zone disables automatic change detection, so the view won't update unless you manually trigger it.
Think about how Angular knows when to update the UI after async work.
Zone.js patches async APIs so Angular knows when async tasks finish and can run change detection automatically, avoiding manual calls.