What is the difference between template-driven and reactive forms?
Model answer
Template-driven forms are built mostly in the template with ngModel and are simple for small forms. Reactive forms are built in the component class with FormGroup, FormControl and FormBuilder, and the template binds to them. They are more explicit, easier to test and better for complex or dynamic forms.
Most teams choose reactive forms for real applications. Both give validation and state such as touched, dirty and valid.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- 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?
- What do touched, dirty and pristine mean?