angular 表达式 {{::}} 中的两个冒号是什么意思?
What does two colons inside an angular expression {{::}} mean?
有什么区别:
{{::office.name}}
和
{{office.name}}
在 angularJS?
{{::office.name}}
语法是 Angular 的 One-Time 绑定,自版本 1.3
起可用
Here's 一个很好的博客解释它。
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).
在许多情况下,值只需要显示在视图中,永远不会从视图或控制器中更新。但是,如果使用 two-way 绑定,$digest
将检查每个循环中表达式的任何变化,这是没有必要的。在这些情况下,应该在表达式之前使用 ::
。如上述声明所述,对于这种情况,这比 two-way 绑定语法更有效。
博客:AngularJS one-time binding syntax from @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!
有什么区别:
{{::office.name}}
和
{{office.name}}
在 angularJS?
{{::office.name}}
语法是 Angular 的 One-Time 绑定,自版本 1.3
起可用
Here's 一个很好的博客解释它。
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).
在许多情况下,值只需要显示在视图中,永远不会从视图或控制器中更新。但是,如果使用 two-way 绑定,$digest
将检查每个循环中表达式的任何变化,这是没有必要的。在这些情况下,应该在表达式之前使用 ::
。如上述声明所述,对于这种情况,这比 two-way 绑定语法更有效。
博客:AngularJS one-time binding syntax from @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!