mercredi 11 mars 2015

select all checkboxes inside ng-repeat


Vote count:

0




Am having a list of check boxes in ng-repeat as:



<div ng-repeat="item in results">
<label class="inlinelabel checkbox">
<input type="checkbox" ng-model="selected[item.id]"><i></i>
</label>
</div>


I would like to select all checkboxes on click of a single check box that is outside the ng-repeat.



<label> Select All </label>
<input type="checkbox" data-ng-model="selectedAll" ng-click="checkAll()">


I tried the code in controller but its not working.



$scope.checkAll=()=>{
if ($scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.employees,function (selected) {
selected[selected.id] = $scope.selectedAll;
});
}


asked 38 secs ago

MANOJ

208






select all checkboxes inside ng-repeat

Aucun commentaire:

Enregistrer un commentaire