[英]Dirty Checking in angular
I was recently going through a pretty interesting article about data binding in angularJS . 我最近浏览了一篇有关angularJS中数据绑定的有趣文章。 I came across a term there : 'Dirty-Checking', which is performed during a $digest
operation. 我在那里碰到一个术语:“脏检查”,它是在$digest
操作期间执行的。 The term sounded quite interesting to me but unfortunately, didn't make much sense about what's dirty over there. 这个词对我来说听起来很有趣,但不幸的是,那里的脏东西并没有多大意义。 Does it concern the constant check on some value ? 它是否涉及对某些值的不断检查?
The term dirty checking
refers to the process of comparing values from before a change ( $digest
cycle) and after a change. dirty checking
一词是指比较更改之前( $digest
循环)和更改之后的值的过程。
This blog does a pretty good job explaining the details. 这个博客在解释细节方面做得很好。
So, when the digest cycle runs in Angular, all the watched scope values (bound to the ui, or using $watch
) are traversed. 因此,当摘要周期在Angular中运行时,将遍历所有监视的范围值(绑定到ui或使用$watch
)。 Each value is resolved and then compared to the value in a previous digest. 解析每个值,然后将其与先前摘要中的值进行比较。 So, it is checking if the values have been changed (whether they are dirty ). 因此,如果值已经改变(它们是否脏了 )它被检查。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.