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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -