As soon as I import FormsModule I start getting this error. I am using MatFormField and it just doesn't seem to work along with FormsModule.
-
Hello, welcome to SO! If you wish to receive (good) answers to your question then you will have to put a bit more effort to your asking. Be more elaborate, explain the issue in detail, include error messages, code snippets, everything that might be relevant. Beleive me, if you put the effort into the question then people will tkae the time to put effort into their answers. – Andrew Adam Sep 25 '20 at 21:06
3 Answers
I just solved my problem with an error message same as yours.
My 2 mistakes are:
I am using formGroupName and formControlName directive without declaring corresponding property in the component class. Also I have to change formGroupName to [formGroup]
I forgot to "import ReactiveFormsModule from the @angular/forms package and add it to your NgModule's imports array."
https://angular.io/guide/reactive-forms#adding-a-basic-form-control
try to follows the above guide to see do that solves your problem.

- 101
- 1
- 9

- 361
- 2
- 4
Please see this other SO answer: https://stackoverflow.com/a/43220824/5100015
While using formControl
, you have to import ReactiveFormsModule
to your imports
array.
Example:
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
@NgModule({
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
MaterialModule,
],
...
})
export class AppModule {}

- 343
- 3
- 10
Do not set formControlName="myField"
.
Instead bind [formControl]="form.controls.myField"
.
Make sure you import ReactiveFormsModule

- 1,969
- 2
- 20
- 31