18
Apr 2020
Reactive form – Follow immutable approach to manage the state of a form
Reactive form keeps the data model pure by providing it as an immutable data structure. It uses an immutable approach to manage the state of a form. In other words, it will not mutate the form state. Each time a change occurs to the form, the FormControl instance will not update the existing data model, it will return a new state (a new data model). Reactive form uses observable operators to return a new data model. In that way, it will always maintain the integrity of the model between changes.
For the template-driven form, it uses the mutable approach. Due to the fact that it relies heavily on two-way data binding with ngModel to update the data model in the component following changes made in the template.