Middle
What state flags does FormControl have?
sobes.tech AI
Answer from AI
FormControl in Angular has several important state flags that help understand the current state of a form field:
- valid / invalid — whether the field is valid according to the set validators.
- pristine / dirty — whether the field has been changed by the user (pristine — no changes, dirty — has changes).
- touched / untouched — whether the field has been focused and then blurred (touched — has been, untouched — not).
- pending — asynchronous validation is in progress.
Example usage:
const control = new FormControl('');
console.log(control.pristine); // true
control.setValue('test');
console.log(control.dirty); // true
These flags are often used for displaying errors and managing form behavior.