How exactly does the AngularJS Digest Loop work?

半世苍凉 提交于 2019-12-02 11:30:51

All your assertions are true, but the digest loop activity is not such a timer function that run always to find changes, but when you add an inplicit watcher (with ng-model or ng-bind) and somethings append on angular context (an input change, a click event ecc.) the digest loop start and apply changes to all active watcher. Is a loop because it run while the previous iteration mark some changes; it stop when there are no changes left or it interate more then 10 times (that mean some design problem).

This is the reason because to have too many watchers could cause performance issues.

A good example to understand that is to create a directive with the link function that change some model property. If you didn't enclose that change on a $apply function or you didn't call $digest the model change will not affect the model watchers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!