try this,
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"> </script>
<div ng-app="app" ng-controller="ctrl">
<form id="selectionForm">
<input type="checkbox" ng-click="toggleAll()" >Select all
<br>
<div ng-repeat = "option in options">
<input type="checkbox" ng-model="option.selected" ng-change="optionToggled()">{{option.value}}
</div>
</form>
{{options}}
</div>
<script>
angular.module("app", []).controller("ctrl", function($scope){
$scope.options = [
{value:'Option1', selected:true},
{value:'Option2', selected:false}
];
$scope.toggleAll = function() {
var toggleStatus = false;
angular.forEach($scope.options, function(itm){ itm.selected = toggleStatus; });
}
});
</script>
這是工作,謝謝,我想問一件事,我們可以做些什麼來禁用未經檢查的複選框。 –
橙色 粉色 並添加$ scope.disableMe1 = false和$ scope.disableMe2 = false; –