We create the model using the two powerful classes provided by Angular—formGroup and formControl:
- FormControl: Tracks the value and state of individual form input elements
- FormGroup: Tracks the value and state of a group of form controls
- FormBuilder: Helps us to develop forms with their initial value and their validations
Just as we imported FormsModule in to our template-driven forms, we will need to import ReactiveFormsModule in to our app.module.ts file.
The updated app.module.ts file should look like the following screenshot:
Armed with all the knowledge about the model-driven form approach, it's time for a hands-on example.