-2

I saw this partial code in an ng-repeat directive

<div ng-repeat="image in images">
    <img ng-src="{{::image.src}}"/>
</div>

Not sure if it's related to the ng-repeat directive.

The page looks the same with or without it but I'm curious what it is.

Mistalis
  • 17,793
  • 13
  • 73
  • 97
Eliran Kanza
  • 45
  • 3
  • 7

3 Answers3

4

This synthax is use for one-time binding in AngularJS:

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).

See the related Plunker.

Mistalis
  • 17,793
  • 13
  • 73
  • 97
0

That is the notation for one-time binding. It's commonly used with ngRepeat for performance reasons.

See https://docs.angularjs.org/guide/expression

Dave
  • 4,375
  • 3
  • 24
  • 30
0

the :: in angular is to bind the data in the template once so Angular does not set a watcher on the field. You'll want to this if you don't expect the data to change as it can help with performance by limiting the number of watchers on the page, here's a link with more info and other performance tips:

http://www.befundoo.com/blog/optimizing-ng-repeat-in-angularjs/

Justin Kruse
  • 1,020
  • 12
  • 27