Listening for NgZone events

With the introduction of Angular 2 comes the concept of zones. Before you begin this recipe, I strongly recommended you to begin by working through the Working with zones outside Angular recipe.

zone.js

zone.js is a library that Angular 2 directly depends upon. It allows Angular to be built upon a zone that allows the framework to intimately manage its execution context.

More plainly, this means that Angular can tell when asynchronous things are happening that it might care about. If this sounds a bit like how $scope.apply() was relevant in Angular 1.x, you are thinking in the right way.

NgZone

Angular 2's integration with zones takes the form of the NgZone service, which acts as a sort of wrapper for the actual Angular ...

Get Angular 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.