dirty checking on Angular

overview

Angular defines a concept of a so called digest cycle. This cycle can be considered as a loop, during which Angular checks if there are any changes to all the variables watched by all the $scopes. So if you have $scope.myVar defined in your controller and this variable was marked for being watched, then you are explicitly telling Angular to monitor the changes on myVar in each iteration of the loop.

Angular定一个了一个概念叫做digest cycle。可以把这个cycle想象成一个循环,在这个循环中Angular通过$scopes检查观察的变量是否发生改变。因此如果你在你的controller中定义$scope.myVar并且这个变量被标记为watched,然后你就显式的告诉Angular在循环的每次迭代中观测myVar的改变

reference

Dirty checking on angular
How do I use $scope.$watch and $scope.$apply in AngularJS?
AngularJS的数据双向绑定是怎么实现的?

你可能感兴趣的:(dirty checking on Angular)