我想在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>