Using Angular 11 with Typescript 4 in Strict Mode I have:
export class ContactComponent implements OnInit {
form: FormGroup;
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.form = this.formBuilder.group({
email: ['', [Validators.required, Validators.email]],
name: ['', [Validators.required, Validators.maxLength(40)]],
});
}
I get the build error:
Property 'form' has no initialiser and is not definitely assigned in the constructor.
Shouldn't the FormGroup be initialised on ngOnInit?