Indicate true value with ng-true-value

Description

The following code shows how to indicate true value with ng-true-value.

Example


Bind two input checkbox to same model<!--from w  ww.  j  a v  a  2s.  c o  m-->
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>

</head>
<body>
  <div ng-app ng-controller="x">
    <input type="checkbox" ng-model="y" ng-true-value="1" ng-false-value="0"> {{y}}
</div>
<script type='text/javascript'>
function x($scope) {
    $scope.y = '1';
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities