What are typed forms, and why do they matter?
Model answer
Since Angular 14, reactive forms are strongly typed: new FormControl<string>('') knows its value is a string (or null unless you use nonNullable). FormGroup values are typed from their controls, so form.value.email is checked by the compiler.
This catches mistakes such as misspelled control names, and makes code safer when refactoring. Use nonNullable controls or fb.nonNullable to avoid null in values, and use getRawValue() when disabled controls must be included.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- What is the difference between template-driven and reactive forms?
- How do you add validation to a reactive form?
- How do you write a custom validator?
- What are async validators and when do you need one?
- What are FormArray and dynamic forms?
- What is the difference between valueChanges and statusChanges, and how do you use them safely?