ngZone.runOutsideAngular() – this runs the code outside the angular zone.
- When some event is fired it tells angular to detect changes.
- If you are using mouseUp() or mouseDown() event, then on every change it tells angular to detect the changes.
- If we don’t want these changes to take place run-time in angular (which reduces performance of the app), we can run it outside of angular zone.
- Contrast to this, if we keenly want to get each and every update then we can use ngZone.run(). Means it will run the change detection in normal.
Angular itself uses ngZone under the hood to detect the changes
So, if we have came out of angular zone, then to come back we use ngZone.run()