There exists the ReactiveFormModule and the FormsModule.
import {
FormsModule,
ReactiveFormsModule
} from "@angular/forms";
When should I use the ReactiveFormModule and what provides this module comparing to the FormModule.
Formsmodule
- Angular 1 tackles forms via the famous ng-model directive. Angular 2 now provides an identical mechanism named also ngModel, that allow us to build what is now called Template-Driven forms.
Unlike the case of AngularJs, ngModel and other form-related directives are not available by default.
ReactiveFormsModule
is for model driven forms. Each form has a state that can be updated by many different interactions and its up to the application developer to manage that state and prevent it from getting corrupted. This can get hard to do for very large forms and can introduce a category of potential bugs.
Where you can write Validations not in html. In this case you can attach many Validations and wrap form.
I got this from here. There is better explanation:
I would like to clarify Oto Lolua's answer. Their explanation for the ReactiveFormsModule was taken out from the wrong context in the article they linked (Oto's explanatory paragraph for the ReactiveFormsModule was actually in reference to FormsModule, not ReactiveFormsModule, in that article).
I'm quoting that same article here (from its summary):
Template Driven Forms are maybe for simple forms slightly less verbose, but the difference is not significant. Reactive Forms are actually much more powerful and have a nearly equivalent readability.
Most likely in a large scale application we will end up needing the functionality of reactive driven forms for implementing more advanced use cases like for example auto-save.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With