AngularJS Tutorial - Set true false value for checkbox input








The following code shows how to set true false value for checkbox input.

Example


<!--from   w  ww  .  jav  a2 s  .co  m-->

<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head>
<body>
  <label class="checkbox">
  <input type="checkbox" 
         ng-model="user.role" 
         ng-true-value="admin" 
         ng-false-value="basic"> Is Administrator</label>
  
  <pre ng-bind="user | json"></pre>
</body>
</html>

The code above is rendered as follows: