Fundamentals of Angular - Forms

Using Forms

In this video...

You will learn how to utilize form elements and form controls in an Angular application, and access the values that a user enters into those controls in our component.

Forms are an important part of interacting with a user. The form element and the various input elements are used in most applications. We'll see how Angular adds additional functionality, directives, and events to allow us to work with forms. Through the use of (ngModel) binding, we can create a JavaScript object that contains all of the data on a form. Through the use of a template ref variable on the form in the format of #formName="ngForm" we can access this data in events. The standard event we listen to is the ngSubmit event on the form. Typically we access the data through (ngSubmit)="handleSubmit(formName.value)" which will pass all of the form data into this event handler.