Aparna Aparna - 5 months ago 49
AngularJS Question

Select All Checkbox scope variable not getting set

I want to implement the functionality of "select All" checkbox should get selected when we select all the sub-items.

Plnkr
Here is the plnkr.

why the "select All" model is not getting set?

Answer

Change your select method to this:

$scope.select = function(){
    angular.forEach($scope.friends, function (item) {
        if(!item.Selected){ // uncheck 'all' if any item is not selected
            $scope.selectedAll = false;
        }
    });
};
Comments