CheckboxControlValueAccessor
From Get docs
< @angular/formsAngular/docs/9/api/forms/checkboxcontrolvalueaccessor
CheckboxControlValueAccessor
directive
A ControlValueAccessor
for writing a value and listening to changes on a checkbox input element.
NgModules
-
ReactiveFormsModule
-
FormsModule
Selectors
input[type=checkbox][formControlName]
input[type=checkbox][formControl]
input[type=checkbox][ngModel]
Properties
Property | Description |
---|---|
onChange: (_: any) => { }
|
The registered callback function called when a change event occurs on the input element. |
onTouched: () => { }
|
The registered callback function called when a blur event occurs on the input element. |
Description
Using a checkbox with a reactive form.
The following example shows how to use a checkbox with a reactive form.
const rememberLoginControl = new FormControl();
<input type="checkbox" [formControl]="rememberLoginControl">
Methods
writeValue() | |||
---|---|---|---|
Sets the "checked" property on the input element. | |||
writeValue(value: any): voidParameters
Returns
|
registerOnChange() | |||
---|---|---|---|
Registers a function called when the control value changes. | |||
registerOnChange(fn: (_: any) => {}): voidParameters
Returns
|
registerOnTouched() | |||
---|---|---|---|
Registers a function called when the control is touched. | |||
registerOnTouched(fn: () => {}): voidParameters
Returns
|
setDisabledState() | |||
---|---|---|---|
Sets the "disabled" property on the input element. | |||
setDisabledState(isDisabled: boolean): voidParameters
Returns
|
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v9.angular.io/api/forms/CheckboxControlValueAccessor