0

我想在 ng-repeat 循环中调用 ng-checked 中的函数,所以我输入ng-checked="isActive('{{item.id}}')". 我期望的是,如果 ng-checked 返回 true,则选中该复选框。但不知何故,我得到了无限循环的这个错误。

[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []

这是控制器。

$http.get('users.php').then(function(response){
  $scope.data = response.data;
});
$scope.isActive = function(id) {
     //Check if user active;
     $http.get('active_users.php?id=' + id).then(function(response){
        if (response.data == true){
           return 'true';
        }
     });

};

并且在视图中

<div ng-repeat="item in data">
   <input type="checkbox" ng-checked="isActive('{{item.id}}')" value="{{item.id}}" /> Active
</div>          
4

0 回答 0