I'm getting this error on my Angular 7 app and I don't know why. Even with some researches it seems that this error doesn't make sense.
This is what I have:
<mat-form-field>
<input matInput placeholder="Name" name="name" [(ngModel)]="data.name" [disabled]="inputReadonly" ngDefaultControl >
</mat-form-field>
I've tried with and withoud ngDefaultControl on mat-form-field and/or input, with and without the name attribute and to move [(ngModel)] on input. Nothing is changed, I'm still receiving the same error.
NG_VALUE_ACCESSORlinkUsed to provide a ControlValueAccessor for form controls.
FormControlName is used to sync a FormControl in an existing FormGroup to a form control element by name.
Defines an interface that acts as a bridge between the Angular forms API and a native element in the DOM.
ngModel
has to be specified on the input
, not on the mat-form-field
. The only purpose of mat-form-field
is to apply some Material CSS
make sure you have MatFormFieldModule
and MatInputModule
imported in your app.module.ts
and also declared in @NgModule({... imports:[MatFormFieldModule,MatInputModule, ...],...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With