Improve this doc View Source

HTML checkbox.

## Directive Info

- This directive executes at priority level 0.

## Usage

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

### Arguments

Param | Type | Details
--- | --- | ---
ngModel | string | Assignable angular expression to data-bind to.
name (optional) | string | Property name of the form under which the control is published.
ngTrueValue (optional) | string | The value to which the expression should be set when selected.
ngFalseValue (optional) | string | The value to which the expression should be set when not selected.
ngChange (optional) | string | Angular expression to be executed when input changes due to user interaction with the input element.

## Example

Edit in Plunker

    <script>
      angular.module('checkboxExample', [])
        .controller('ExampleController', ['$scope', function($scope) {
          $scope.value1 = true;
          $scope.value2 = 'YES'
        }]);
    </script>
    <form name="myForm" ng-controller="ExampleController">
      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() {
      var value1 = element(by.binding('value1'));
      var value2 = element(by.binding('value2'));

      expect(value1.getText()).toContain('true');
      expect(value2.getText()).toContain('YES');

      element(by.model('value1')).click();
      element(by.model('value2')).click();

      expect(value1.getText()).toContain('false');
      expect(value2.getText()).toContain('NO');
    });