我正在尝试学习如何牢固地使用 Angular,但我无法理解 official website 上的指南和示例中使用的一些语法。 . 在定义按钮表单控件时,我看到了这个模板:
<div><button type="{{::to.type}}" class="btn btn-{{::to.btnType}}" ng-click="onClick($event)">{{to.text}}</button></div>
我的问题是:“to.type”和“to.btnType”之前的“::”是什么意思? 它是如何被使用的? 这与这样定义它有何不同:
<a ng-class="{'btn-primary': to.isPrimary, active: to.isActive}" class="btn, btn-default"/>
最佳答案
这是一个one-time binding expression ,它阻止了通常会导致性能问题的观察者的扩散。
这里有一些有用的读物:http://blog.thoughtram.io/angularjs/2014/10/14/exploring-angular-1.3-one-time-bindings.html
关于javascript - 的含义::以 Angular 形式表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32861461/