Do bindings nested inside of a lazy one-time ng-repeat binding bind just once?

Gil Birman picture Gil Birman · May 28, 2014 · Viewed 17.3k times · Source

My understand is that in the following code, both bindings will lazily bind only once:

<li ng-repeat="item in ::items">{{::item.name}}</li>

However, in the following case will {{item.name}} be updated every digest?

<li ng-repeat="item in ::items">{{item.name}}</li>

And how does one-time binding effect nested ng-repeats ?

<li ng-repeat="item in ::items">
  <span ng-repeat="thing in item.things">{{thing.name}}</span>
</li>

Answer

tasseKATT picture tasseKATT · May 28, 2014

Scenario 1:

<li ng-repeat="item in ::items">{{::item.name}}</li>

Both expressions will be one-time bound. Adding an item or changing an existing item's name will not be reflected.

Demo: http://plnkr.co/edit/53r8FCmcNK4MmM6Uzxp2?p=preview

Scenario 2:

<li ng-repeat="item in ::items">{{item.name}}</li>

First expression will be one-time bound. Adding an item will not be reflected. Changing an existing item's name will be reflected.

Demo: http://plnkr.co/edit/52wTEb8ze2FKRDDcS9Ow?p=preview

Scenario 3:

<li ng-repeat="item in ::items">
  <span ng-repeat="thing in item.things">{{thing.name}}</span>
</li>

First expression will be one-time bound. Adding new item will not be reflected. Adding a new thing and changing existing thing's name will be reflected.

Demo: http://plnkr.co/edit/HkObhkJtUnFEHBAzFUmN?p=preview