NumberValueAccessor
directive
The ControlValueAccessor
for writing a number value and listening to number input changes. The value accessor is used by the FormControlDirective
, FormControlName
, and NgModel
directives.
NgModules
Selectors
input[type=number][formControlName]
input[type=number][formControl]
input[type=number][ngModel]
Properties
Property | Description |
---|---|
onChange: (_: any) => { } | The registered callback function called when a change or input event occurs on the input element. |
onTouched: () => { } | The registered callback function called when a blur event occurs on the input element. |
Description
Using a number input with a reactive form.
The following example shows how to use a number input with a reactive form.
const totalCountControl = new FormControl();
<input type="number" [formControl]="totalCountControl">
Methods
writeValue() | |||
---|---|---|---|
Sets the "value" property on the input element. | |||
|
value | number | The checked value |
Returns
void
registerOnChange() | |||
---|---|---|---|
Registers a function called when the control value changes. | |||
|
fn | (_: number) => void | The callback function |
Returns
void
registerOnTouched() | |||
---|---|---|---|
Registers a function called when the control is touched. | |||
|
fn | () => void | The callback function |
Returns
void
setDisabledState() | |||
---|---|---|---|
Sets the "disabled" property on the input element. | |||
|
isDisabled | boolean | The disabled value |
Returns
void
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v8.angular.io/api/forms/NumberValueAccessor