What does the formControl directive do?
formControl is a directive that binds a form element to a FormControl instance in reactive forms.
It:
- connects an HTML element to a
FormControlobject, which holds the current value, validators, and state; - automatically synchronizes data between the DOM and the model;
- tracks statuses such as
valid,touched,dirty.
Example:
typescript
name = new FormControl('');html
<input [formControl]="name">If the user changes the field's value, FormControl updates immediately, and vice versa: any change in FormControl is reflected in the field.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.