FormControl
Tracks the value and validation state of a single form field.
Syntax
new FormControl(initialValue, validators?) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
initialValue | any | No | Initial value (or a state object with disabled). |
validators | ValidatorFn | ValidatorFn[] | No | Synchronous validators for the control. |
Returns
FormControl — A reactive control with value and status.
Examples
import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
@Component({
selector: 'app-x',
standalone: true,
imports: [ReactiveFormsModule],
template: `<input [formControl]="email" />`,
})
export class XComponent {
email = new FormControl('', { nonNullable: true, validators: [Validators.email] });
}
Notes
Bind with `[formControl]` and import ReactiveFormsModule. Use
`nonNullable: true` so reset() restores the initial value instead of null.
Read state via value, valid, errors, and the valueChanges/statusChanges
observables.