有什么区别:
{{::office.name}}
和
{{office.name}}
在 angularJS 中?
最佳答案
One-time binding From Angular Docs.
An expression that starts with
::
is considered a one-time expression. One-time expressions will stop recalculating once they are stable, which happens after the first digest if the expression result is a non-undefined value (see value stabilization algorithm below).
在许多情况下,值只需要显示在 View 中,永远不会从 View 或 Controller 中更新。但是,如果使用双向绑定(bind),$digest
将检查每个循环中表达式的任何变化,这是没有必要的。在这些情况下,应该在表达式之前使用 ::
。如上述声明所述,对于这种情况,这比双向绑定(bind)语法更有效。
博客:AngularJS one-time binding syntax来自 @Todd Motto
In a nut shell, when we declare a value such as
{{ ::foo }}
inside the DOM, once this value becomes defined, Angular will render it, unbind it from the watchers and thus reduce the volume of bindings inside the$digest
loop. Simple!
关于javascript - Angular 表达式 {{::}} 中的两个冒号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34678400/