class is called several times in directive of angular?

This question already has an answer here:

  • How does data binding work in AngularJS? 13 answers

  • All expression that you use in AngularJS get evaluated multiple times when a digest cycle runs. This is done for dirty checking which validates whether the current value of expression is different from the last value.

    This means you cannot rely on how many times a method gets called if used within an expression.

    See the section "Scope Life cycle" to understand how it happens http://docs.angularjs.org/guide/scope


    AngularJS compiles DOM so it might create div and execute ng-class few times behind the scenes. Anyways, ng-class is expected to be used in another way http://docs.angularjs.org/api/ng.directive:ngClass

    链接地址: http://www.djcxy.com/p/23110.html

    上一篇: $ Angular $ scope。$ watch如何工作?

    下一篇: 在角度指令中多次调用类?