CheckboxControlValueAccessor

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

@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 }

选择器

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

说明

Example

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

属性

属性名类型说明
onChange
onTouched

方法

writeValue(value: any): void

参数

value

Type: any.

返回值

void

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

参数

fn

Type: (_: any) => { }.

返回值

void

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

参数

fn

Type: () => { }.

返回值

void

setDisabledState(isDisabled: boolean): void

参数

isDisabled

Type: boolean.

返回值

void