My webpage has a reactive form, but I keep encountering an error message that states:
ERROR Error: formControlName must be used with a parent formGroup directive. Make sure to include a formGroup directive and pass it an existing FormGroup instance (you can create one in your class).
I am puzzled by this error because I have already defined a formGroup instance.
This is the HTML code I am using:
<form [formGroup]="singleRecipientForm">
<textarea #textInput placeholder="user e-mail" formControlName="email"></textarea>
<button type="submit" (click)="sendMailTextInput(textInput.value)">Send invite </button>
</form
And here is how my Typescript file looks:
singleRecipientForm: FormGroup;
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {
this.singleRecipientForm = this.formBuilder.group({
email: ['', [Validators.required]],
});
}
I cannot figure out why I keep getting this error message.