I created a form by calling a function from the constructor
constructor(private userManagementService: UserManagementService, private fb:FormBuilder) {
this.createForm();
}
createForm(){
this.signupForm = this.fb.group({
firstName:['',Validators.required],
lastName:['',Validators.required],
email:['',Validators.required],
password:['',Validators.required]
});
}
I suppose I could also create the form in ngOnInit
constructor(private fb:FormBuilder) {
}
ngOnInit{
this.signupForm = this.fb.group({
firstName:['',Validators.required],
lastName:['',Validators.required],
email:['',Validators.required],
password:['',Validators.required]
});
}
}
What is the difference between the two approaches? Is one better than the other?