Good day! There is a conclusion in the cycle
<div ng-repeat="item in items"> <p>{{ item.title }}</p> <input type="checkbox" ng-model="checkboxmodel" ng-change="checkboxmodel==1? func1(item) : func2(item)" ng-true-value="1" ng-false-value="0" /> </div>
Those. for each item must be your checkbox. Its value is not contained in the item, but is additionally calculated. With checked / unchecked, everything works, the functions func1(item), func2(item)
worked out. But how to set the initial value of the checkbox? Now the model is one for all checkboxes, and there is no possibility to set the value of a specific checkbox through $scope.checkboxmodel
Trying to do through arrays:
<div ng-repeat="item in items"> <p>{{ item.title }}</p> <input type="checkbox" ng-model="ItemsCtrl.checkboxes[$index]" ng-change="ItemsCtrl.checkboxes[$index]==1? func1(item) : func2(item)" ng-true-value="1" ng-false-value="0" /> </div>
In the ItemsCtrl controller, where items are added, added:
$scope.checkboxes = [];
Then I try to add a new item - a checkbox with a value of 1:
$scope.checkboxes.push(1);
But, of course, does not work. Tell me please.