I want to call a function in ng-checked inside a ng-repeat loop, so I type ng-checked="isActive('{{item.id}}')"
. What I expect is if ng-checked returns true, the checkbox is checked. But somehow I get this error with unlimited loops.
[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
This is the controller.
$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';
}
});
};
And in view
<div ng-repeat="item in data">
<input type="checkbox" ng-checked="isActive('{{item.id}}')" value="{{item.id}}" /> Active
</div>