When to Use Reactive and Template Forms
Let's explore the differences between the reactive and template forms. We’ll also look at the reasons why we could use either.
We'll cover the following...
Difference between reactive and template-driven form
The difference between the template-driven form and the Reactive form is that the template form binds closely to a model through ngModel
. As the form is submitted, the model is already set.
Reactive forms take a different approach – they create a model of the form, which is attached to the form using the FormGroup
. This model then observes the form, and as data is entered into the form, the model updates. This makes the state of the model available at any time so that if the user has just entered the first part of the form, we have a model representation of this. With each change to the form, we have a new instance of our form model.
This means we can start taking advantage of the ...