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 - Angular Tutorial
From the course: Angular: API Communication and Authentication
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
GET route for the API4m 55s
-
(Locked)
POST route for the API3m 54s
-
(Locked)
Using @angular/http to retrieve contacts, part 13m 8s
-
(Locked)
Using @angular/http to retrieve contacts, part 23m 52s
-
(Locked)
Creating a new route for adding a new contact6m 12s
-
(Locked)
Using ngForm for form submission2m 49s
-
(Locked)
Writing the onSubmit() function4m 16s
-
-
-
-
-