import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css']
})
export class SignupComponent implements OnInit {
signupForm: FormGroup | undefined;
constructor(public formBuilder: FormBuilder) {
}
ngOnInit(): void {
this.signupForm = this.formBuilder.group({
username:[' ', Validators.required],
email:[' ', Validators.required],
password:[' ',[Validators.required]]
})
}
}
Additionally, there is a coding issue:
src/app/auth/signup/signup.component.ts:6:16 6 templateUrl: './signup.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ An error has been detected in the template of component SignupComponent.
Error: src/app/auth/signup/signup.component.html:40:110 - error TS2531: Object is possibly 'null'.
40 <span *ngIf="!signupForm.get('password').valid && signupForm.get('password').touched"> ~~~~~~~
src/app/auth/signup/signup.component.ts:6:16 6 templateUrl: './signup.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~ An error has occurred in the template of component SignupComponent.
Error: src/app/auth/signup/signup.component.ts:10:3 - error TS2564: Property 'signupForm' has no initializer and is not definitely assigned in the constructor.