Issue
Property 'group' does not exist on type 'typeof FormBuilder'
here is the code
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
export class LoginPageForm{
constructor(private formBuilder = FormBuilder){}
createForm(): FormGroup{
return this.formBuilder.group({
email: ['', [Validators.required]],
password: ['', [Validators.required]]
});
}
}
Solution
From:
constructor(private formBuilder = FormBuilder){}
you are declaring the formBuilder
and initializing it with the value of FormBuilder
type.
formBuilder = typeof(FormBuilder)
isn't equivalent to
formBuilder: FormBuilder
which store FormBuilder
instance.
Instead, specify formBuilder
as FormBuilder
type.
constructor(private formBuilder: FormBuilder){}
Answered By - Yong Shun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.