angular2-playground icon indicating copy to clipboard operation
angular2-playground copied to clipboard

How does the by service way work?

Open cubika opened this issue 10 years ago • 1 comments

For example, if FriendInput add an item to FriendsService, how does it notify FriendList that an item is added? I notice that no explicit call were made when new item added.

cubika avatar Jun 12 '15 08:06 cubika

Right, there is no explicit call to notify FriendList that something has changed. There is also no $watch or something similar in FriendList that registers a callback handler.

In Angular 2 it all works automatically. Behind the scenes you have Zone.js that intercepts all asynch calls and triggers Angular's change detection.

The short (but good) description of what Zone.js does for Angular could be read here: https://github.com/angular/angular/blob/master/modules/angular2/docs/core/12_zones.md

Cheers ;-)

SekibOmazic avatar Jun 12 '15 08:06 SekibOmazic