In AngularJS 2, most zone-related examples and articles center on the zone
object and functions like zone.fork
and zone.run
. For example, this article and this video focus on the zone
object.
But the AngularJS 2 documentation presents a class named NgZone. I'd like to use methods like onTurnStart
and onTurnDone
, but I can't find any examples of these methods being used. Should I bother using this class at all?
In Angular2 the NgZone class is a wrapper around the zone.js framework. Also the dependency injector will pass in the
zone
that relates to that component.So the answer is: If you are going to use
zone
at all. Then definitely useNgZone
.The documentation for NgZone can be found here including all of the methods and their arguments.