Tag: angularjs track by

当使用$ index跟踪时,ng-init没有第二次调用

HTML: {{employeeName}} 控制器: $scope.initUserDecision = function(row,index){ $scope.employeeName=row[“name”]; } $scope.rows=[{id:1,name:’siva’},{id:2,name:’ram’}] //changing $scope.rows in button click event and used $scope.$apply as well angular.element(document).on(“click”, “#change”, function () { $scope.rows=[{id:1,name:’ravi’},{id:2,name:’raj’}] $scope.$apply(); }); ng-init函数在tr初始化时首次调用。 如果我点击更改按钮行集合被更改,它将不会再次调用ng-init 。 如果我通过$index ng-init删除跟踪调用时间。 当我通过$index使用track时,它只被调用了一次。 为什么会这样? 对此有任何想法。