Javascript 默认选择angularjs中的所有复选框

Javascript 默认选择angularjs中的所有复选框,javascript,angularjs,Javascript,Angularjs,我正在用angularjs创建一个应用程序。当页面打开时,显示选中的所有复选框时出现问题 这是我的密码: <div class="check_box"> <input type="checkbox" id="checkbox1" name="checkbox" ng-model="selectedAllStatus" ng-click="checkAllTypes()"> <label for="checkbox1"><span for="checkbo

我正在用angularjs创建一个应用程序。当页面打开时,显示选中的所有复选框时出现问题

这是我的密码:

<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>

单击按钮时,选中所有复选框(这正在工作),但我希望当页面打开时,应选中所有复选框。

您可以在加载模板之前在控制器中执行此操作

 $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()

模拟点击打开的页面。可能重复
 $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()