Saturday, March 14, 2015

ng-checked directive

The ng-checked directive is used with checkbox controls to set the checkbox status to checked/un-checked. The status of the checkbox can be controlled from a variable/property in the model object, just set the model property value to the ng-checked directive and the checkbox will automatically change its state based on the value of the property.

In the following example the $scope.checkedStatus property controls the state of the checkbox control.

<html ng-app="changeCheckboxApp">
    <meta charset="utf-8">
    <title>AngularJS - Basic</title>
    <script src="angular.min.js"></script>
var app = angular.module('changeCheckboxApp', []);

function changeCheckboxController($scope) {
          $scope.checkedStatus = true;
          <div ng-controller="changeCheckboxController">
                   Checked Status: {{checkedStatus}}    <input type="checkbox" ng-model="checkedFlag" ng-checked="checkedStatus"> <br/><br/>


Search Flipkart Products:

No comments: