Ng-Checked-3

 

In this example of Ng-Checked, We have multiple checkboxes and their model names are different and Clicking on the checkboxes will show the output in json format. See the working example

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body ng-app="checkedExample"> <div ng-controller="ExampleController"> <div class="container"> <input type="checkbox" ng-checked="testModel.child_1 && testModel.child_2 && testModel.child_3 && testModel.child_4 && testModel.child_5" ng-model="isChecked" /> <b>Select All</b><br /> <input type="checkbox" ng-model="testModel.child_1" ng-checked="isChecked" /> First<br /> <input type="checkbox" ng-model="testModel.child_2" ng-checked="isChecked" /> Second<br /> <input type="checkbox" ng-model="testModel.child_3" ng-checked="isChecked" /> Three<br /> <input type="checkbox" ng-model="testModel.child_4" ng-checked="isChecked" /> Four<br /> <input type="checkbox" ng-model="testModel.child_5" ng-checked="isChecked" /> Five<br /> <br /> <b>isAllSelected = {{isChecked}}</b> <pre>{{testModel|json}}</pre> <hr /> </div> </div> <script> var app = angular.module("checkedExample", []); app.controller('ExampleController', ['$scope', function ($scope) { }]); </script> </body> </html>
Output