Ng-Checked-8

 

Ng-checked is basically used to set the selection of check boxes and radio buttons etc, Here in our example we are taking 1 check box and 2 radio buttons where radio buttons are dependent on check box selection means one radio button will be selected if check box is checked and other one is selected if check box is unchecked. Lets take an example of party :) :

 
 
 
<!DOCTYPE html> <html lang="en-US"> <head> <title>Learn It HTML Template</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="sampleApp"> <div ng-controller="sampleController"> Are you going for party tonight: <input type="checkbox" ng-model="checked"> <br/> <br/> You should go, Complete this example and rest examples you can learn tomorrow :), So click on the check box above: <br/> <br/> <input id="checkSlave" type="radio" ng-checked="checked">Yeah :) <input id="checkSlave" type="radio" ng-checked="!checked"> Sad :( </div> <script> var app = angular.module("sampleApp", []); app.controller('sampleController', ['$scope', function ($scope) { }]); </script> </body> </html>
Output