javascript - Default Select all checkboxes in angularjs -
i creating app in angularjs. have problem while showing checkbox selected when page open.
here code:
<div class="check_box"> <input type="checkbox" id="checkbox1" name="checkbox" ng-model="selectedallstatus" ng-click="checkalltypes()"> <label for="checkbox1"><span for="checkbox1">all</span></label> </div> </li> <li ng-repeat="customersflowslist in customersflows | unique:'type'" ng-init="checkalltypes()"> <div class="check_box"> <input type="checkbox" id="checkbox1" name="checkbox" ng-model="filter[customersflowslist.type]"> <label for="checkbox1"><span for="checkbox1">{{customersflowslist.type | customertype}}</span></label> </div> </li>
here js code:
$scope.checkallstatus = function() { console.log($scope.selectedall) if ($scope.selectedall) { $scope.selectedall = true; } else { $scope.selectedall = false; } angular.foreach($scope.customersflows, function (customersflowslist) { $scope.filterlink[customersflowslist.linkstatus] = $scope.selectedall; }); }
on click of button checkboxes selected(this working),but want when page open checkboxes should selected.
you can in controller before template load
$scope.checkallstatus = function() { console.log($scope.selectedall) if ($scope.selectedall) { $scope.selectedall = true; } else { $scope.selectedall = false; } angular.foreach($scope.customersflows, function(customersflowslist) { $scope.filterlink[customersflowslist.linkstatus] = $scope.selectedall; }); } $scope.selectedallstatus = true; $scope.checkallstatus()
Comments
Post a Comment