From the course: Angular: API Communication and Authentication

Unlock the full course today

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

Using ngForm for form submission

Using ngForm for form submission - Angular Tutorial

From the course: Angular: API Communication and Authentication

Start my 1-month free trial

Using ngForm for form submission

- [Instructor] In the previous video, we went ahead and added a new route, along with the form that will be used to input the information for adding new contacts. We will be adding functionality to this simple form. Or as I like to say, angularize the form. When working with forms in Angular, be sure to import the forms module from Angular forms and include it in the imports property of the NG Module. Because we are importing the forms module, Angular will attach NG form directive to any form. This makes the NG form object available in review. In our form we will create a local template variable contact form and assign it the value of NG form. Note that this isn't the string NG form, but rather the NG form object. When the form is submitted, we want to call the on submit function on the component, with the local contact form variable as its argument. The next step is to add the NG model directive to all of our inputs. This will create an association between this inputs, and the NG…

Contents