From the course: Learning Angular
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Building reactive forms
From the course: Learning Angular
Building reactive forms
- [Narrator] In order to create the form, let's add a component for it first. It is going to be a signup form where users can input information to sign up for a course. I'm going to generate a component, and I'm going to type ng generate component, and I'm going to call it sign-up-form. And there we go. It has created the sign-up-form. And here it is. Let's open up the TypeScript and the HTL. Alright, starting with TypeScript, inside the SignupFormComponent, I'm going to find our form model using FormGroup, FormBuilder, and Validators. In order to do that, I'm going to need to import the CommonModule and the ReactiveFormsModule. Let's give our class the property SignUpForm, which is of type FormGroup. And I'm going to make your class implement OnInIt, and in the ngOnInIt I'm going to specify the SignUpForm. And in order to do this, I will need to use the FormBuilder, and I'm going to inject that in my constructor that I don't have yet. FormBuilder, fb of type FormBuilder, and while…