I am currently working on a checkbox functionality in my project that is bound to an ng-model:
<input type="checkbox" ng-change="toggleAll(globalChecked)" ng-model="globalChecked">
The toggleAll function is responsible for accessing the globalChecked value and performing additional logic in the controller:
$scope.toggleAll = function(val) {
if ($scope.objects == undefined) {
return
}
for (var i = 0; i < $scope.objects.length; ++i) {
$scope.objects[i].checked = val;
}
}
However, I have noticed a issue where clicking the checkbox for the first time triggers the toggleAll function, but the value of 'val' (or globalChecked value) remains false.
I am wondering if there is something that I may have overlooked in this implementation?