linkCheckboxControlValueAccessor
npm Package | @angular/forms |
---|---|
Module | import { CheckboxControlValueAccessor } from '@angular/forms'; |
Source | forms/src/directives/checkbox_value_accessor.ts |
linkOverview
@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
}
linkSelectors
input[type=checkbox][formControlName]
input[type=checkbox][formControl]
input[type=checkbox][ngModel]
linkDescription
The accessor for writing a value and listening to changes on a checkbox input element.
linkExample
<input type="checkbox" name="rememberLogin" ngModel>
linkConstructor
constructor(_renderer: Renderer2, _elementRef: ElementRef)