angular.module.ng.$compileProvider.directive.input.checkbox

Description

HTML checkbox.

Usage

<input type="checkbox"
       ng-model="{string}"
       [name="{string}"]
       [ng-true-value="{string}"]
       [ng-false-value="{string}"]
       [ng-change="{string}"]>

Parameters

Example

 <script>
   function Ctrl($scope) {
     $scope.value1 = true;
     $scope.value2 = 'YES'
   }
 </script>
 <form name="myForm" ng-controller="Ctrl">
   Value1: <input type="checkbox" ng-model="value1"> <br/>
   Value2: <input type="checkbox" ng-model="value2"
                  ng-true-value="YES" ng-false-value="NO"> <br/>
   <tt>value1 = {{value1}}</tt><br/>
   <tt>value2 = {{value2}}</tt><br/>
  </form>
  it('should change state', function() {
    expect(binding('value1')).toEqual('true');
    expect(binding('value2')).toEqual('YES');

    input('value1').check();
    input('value2').check();
    expect(binding('value1')).toEqual('false');
    expect(binding('value2')).toEqual('NO');
  });