0

If I have an ng-repeat directive iterating through a list of lists via a one-time binding, does a nested ng-repeat through each of the inner lists also need a one-time binding, or is that redundant?

<div ng-repeat="list in ::$ctrl.lists">
  <span ng-repeat="item in list">{{item}}</span>
</div>

Do I need to change the inner ng-repeat to item in ::list? $ctrl.lists will never change in any manner.

4

1 回答 1

1

没有指定继承的地方,如果绑定了数组,则事件,数组内的对象仍然可以更改,因此最好也将'::'用于span循环。

http://jsfiddle.net/vw2fjxys/64/

var a = [1,2,3]
    setTimeout(function(){
    console.log(2)
        a.length = 2
      $scope.$apply();
    },3000)
$scope.lists = [a];

您可以在 2 秒后在示例中看到,使用 :: 它不会为内部循环重新计算,但没有它。

于 2018-04-18T22:17:45.167 回答