CheckboxControlValueAccessor

directive

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

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/forms/CheckboxControlValueAccessor