Check All , UnCheck All - AngularJs
Code to check and uncheck all using angularjs
by Divya Manu
HTML
<div ng-controller="checkboxController">
<ul >
<li>Check All
<input type="checkbox" ng-model="v" ng-click="checkAll()" />
</li>
<li ng-repeat="item in Items">
<label>{{item.Name}}
<input type="checkbox" ng-model="item.Selected" />
</label>
</li>
</ul>
<input type="button" ng-click="x()" value="eto" />
</div>
JavaScript
angular.module("CheckAllModule", [])
.controller("checkboxController", function checkboxController($scope) {
$scope.Items = [{
Name: "Item one"
}, {
Name: "Item two"
}, {
Name: "Item three"
}];
$scope.x = function () {
alert("x");
$scope.Items[0].Selected=true;
};
$scope.checkAll = function () {
if ($scope.v) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.Items, function (item) {
item.Selected = $scope.selectedAll;
});
};
});