{ "id": "api/forms/NumberValueAccessor", "title": "NumberValueAccessor", "contents": "\n\n
\n
\n
\n \n API > @angular/forms\n
\n \n
\n \n
\n

NumberValueAccessorlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

The ControlValueAccessor for writing a number value and listening to number input changes.\nThe value accessor is used by the FormControlDirective, FormControlName, and NgModel\ndirectives.

\n\n \n
\n \n \n \n \n\n

NgModuleslink

\n\n\n\n \n
\n

Selectorslink

\n \n
    \n
  • input[type=number][formControlName]
  • \n \n
  • input[type=number][formControl]
  • \n \n
  • input[type=number][ngModel]
  • \n \n
\n \n
\n\n\n\n \n\n\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n \n

Using a number input with a reactive form.link

\n

The following example shows how to use a number input with a reactive form.

\n\nconst totalCountControl = new FormControl();\n\n\n<input type=\"number\" [formControl]=\"totalCountControl\">\n\n\n
\n \n\n \n\n \n\n \n\n \n \n \n\n
\n
\n\n\n" }