0
What is NgZone in Angular? When and why would you use ngZone.runOutsideAngular()?
subina kallyani
medium
0completed
330
Answer
NgZonehelps Angular know when to trigger change detection by “zones” wrapping async operations- For expensive operations (e.g. scroll, mousemove, animations), you may run code outside Angular so change detection doesn’t run on every event
- Then when you need to update UI, call
ngZone.run() - Be careful: code outside Angular can’t call Angular APIs that rely on zone unless you wrap them
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0