Angular lazy one-time binding for expressions

后端 未结 1 1686
迷失自我
迷失自我 2020-12-07 21:57

AngularJS has a new feature since the version 1.3.0-beta.10: the \"lazy one-time binding\".

Simple expressions can be prefixed with ::, telling angular

相关标签:
1条回答
  • 2020-12-07 22:23

    Yes. You can prefix every expressions with ::, even the ones in ngIf or ngClass:

    <div ng-if="::(user.isSomething && user.isSomethingElse)"></div>
    <div ng-class="::{classNameFoo: user.isSomething}"></div>
    

    Actually, the code simply checks that the two first characters in the expression are : in order to activate the one-time binding (and then removes them, thus the parenthesis aren't even needed). Everything else remains the same.

    0 讨论(0)
提交回复
热议问题