AngularJS Tutorial - ng-false-value sets false value for checkbox








The following code shows how to use ng-false-value to set false value for checkbox.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w w  w. ja v a2 s.  c  o  m-->
<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: