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]]
});
}
}
CodePudding user response:
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){}