AngularJS Tutorial - Bind ng-checked to a scope value








You can bind ng-checked to a scope value.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from w ww . j  a v  a 2  s. co m-->
<body>
  <div ng-app ng-controller="x">
     <input type="checkbox" ng-checked="y"> {{y}}
  </div>
<script type='text/javascript'>
function x($scope) {
    $scope.y = 1;
}
</script>
</body>
</html>

The code above is rendered as follows: