AngularJS Tutorial - Link checkbox and button by scope








The following code shows how to link checkbox and button by scope.

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  www  . j a  v  a  2 s .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: