Search code examples
javascriptangularjsbindonce

Bindonce on ngRepeat


What is the effect of using the native bindonce on an ng-repeat object? For example:

ng-repeat="data in ::stuff"

Does this mean every item in 'stuff' has the watcher removed? Or do you still need to apply bindonce to every child bind in the repeat like this?

<div ng-repeat="data in ::stuff">
  <span ng-bind="::data.thing"></span>
</div>

Solution

  • For data in ::stuff, the array is bound once and a $watcher is not created after bound the first time, and therefore any changes to that array will not update your ng-repeat's view.

    However, unless you have ::data.thing changes to individual objects will still be registered. Those watchers belong to the object itself and not the shallow contents of the array.

    See my plunkr below.

    <iframe src="http://embed.plnkr.co/3gbmI2kqd3rT7z0GEyK7/"></iframe>