From the course: Angular Essential Training (2019)

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Model-driven forms

Model-driven forms - Angular Tutorial

From the course: Angular Essential Training (2019)

Start my 1-month free trial

Model-driven forms

- [Instructor] The model-driven or reactive approach is another way to handle building forms in Angular. It has a lot of similarities to the template driven approach but the big difference is the form is built in the component class. That allows you to have a contract that your form needs to adhere to, the ability to set up validation rules, subscribed to field value changes and ultimately unit tests your form logic without any UI layer. So template driven gives you an easy way to get up and running. Whereas model driven allows you to take your forms wherever they need to go. Let's refactor the mediaItemForm to be model driven or ReactiveForms based. So, model-driven forms are built using the ReactiveForms module instead of the FormsModule. We need to update the app module to import and use that instead of FormsModule. Now, just so you know, it is possible to import both of these together in the case where your…

Contents