This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

CheckboxControlValueAccessor

npm Package @angular/forms
Module import { CheckboxControlValueAccessor } from '@angular/forms';
Source forms/src/directives/checkbox_value_accessor.ts

Overview

      
      @Directive({
    selector: 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]',
    host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' },
    providers: [CHECKBOX_VALUE_ACCESSOR]
})
class CheckboxControlValueAccessor implements ControlValueAccessor {
  onChange: (_: any) => { }
  onTouched: () => { }
  writeValue(value: any): void
  registerOnChange(fn: (_: any) => {}): void
  registerOnTouched(fn: () => {}): void
  setDisabledState(isDisabled: boolean): void
}
    

Selectors

      
      input[type=checkbox][formControlName]
input[type=checkbox][formControl]
input[type=checkbox][ngModel]
    

Description

The accessor for writing a value and listening to changes on a checkbox input element.

Example

      
      <input type="checkbox" name="rememberLogin" ngModel>
    

Constructor

      
      constructor(_renderer: Renderer2, _elementRef: ElementRef)
    

Members

      
      onChange: (_: any) => { }
    

      
      onTouched: () => { }
    

      
      writeValue(value: any): void
    

      
      registerOnChange(fn: (_: any) => {}): void
    

      
      registerOnTouched(fn: () => {}): void
    

      
      setDisabledState(isDisabled: boolean): void