And I cry whenever I add a sad song and I watch that part of my slideshow. Reactive forms come as the best choice to build complex forms.Now we have created Form Group but our HTML is yet uninformed about the Form object use of form Group, form Control Name, form Group Name, and form Array Name directives.For this we will assign form object to HTML form like the following: We can reuse the custom validator that we used in our previous article.
You can refer the example in git here: https://github.com/agiratech/angular4-reactive-form-exercise2In the above example, we have learned about model-driven or Reactive forms and how to work with Reactive forms.
See below: Above you can see that we have used classes Validators and Custom Validators to give validation.
Each Form Control will accept multiple validations.
this gives us more control over the form values and validations when compared to template-driven forms.
Reactive Forms are also known as “model-driven” forms because they use the reactive model-driven technique to handle the form data which explicitly manages the form data between component and template.