Reputation: 293
In some angular js files, I see below syntax. What does a double colan "::" mean?
<span>{{::x}}</span>
<div>{{::y.z()}}</div>
Upvotes: 4
Views: 2137
Reputation: 28259
This feature is called one-way databinding, and appeared since Angular 1.3. For older versions, there is an equivalent add-on solution called bindonce.
From Angular JS documentation :
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
Basically, when you write :
{{::x}}
angular will destroy the watcher when x
will be defined. The counterpart of it is that x
won't be updated anymore in the view if his value changes after that destroy.
Upvotes: 2
Reputation: 21766
This syntax is used for one time binding. It provides the ability to render data once and let it persist without being affected by future Model updates. See more details in the link below:
https://www.binpress.com/tutorial/speeding-up-angular-js-with-simple-optimizations/135
Upvotes: 1