Custom form controls and ControlValueAccessor
Learn Custom form controls and ControlValueAccessor (Module 11 · Angular Forms, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Your own input component • A custom form control is a component (a star rating, a date picker, a tag input) that can be used with formControlName or [(ngModel)] just like a normal input. • The glue is ControlValueAccessor (CVA): an interface that tells Angular how to write a value into your component and how your component reports changes. Think of it as an adapter plug between the forms system and your component, like a Java interface that lets any class be used as a Comparator.
More lessons in Module 11 · Angular Forms
- Module 11 overview and checklist
- Template-driven vs reactive forms
- Form model: FormControl, FormGroup, FormArray, FormBuilder
- Form states and built-in validators
- Custom, cross-field and async validation, error messages
- Dynamic, nested and conditional forms, submit and reset
- Form accessibility, testing and performance