AngularJS Tutorial - Bind checkbox to scope value








The following code shows how to bind checkbox to scope value.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
var TermsController = function($scope) {
    $scope.terms = {<!--from   w  w  w  .  j  av  a2s  .c om-->
        label : "After"
    }
}
</script>
</head>
<body ng-app>
  <div ng-app>
    <div ng-controller="TermsController" ng-cloak>
        <input type="checkbox" ng-model="terms.label">
        <button type="submit" ng-bind="terms.label">Before</button>
    </div>
</div>
</body>
</html>

The code above is rendered as follows: