Friday, April 19, 2019

mat-form-field must contain a MatFormFieldControl.


Hi Guys ,



Today I have faced this error :

ERROR Error: mat-form-field must contain a MatFormFieldControl.

Later I have found out that I have missed to add the attribute matInput .

<mat-form-field>
<input type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>

Once I added the attribute to the input field matInput , the error was resolved .

<mat-form-field>
<input matInput type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>


Video Link :

Full stack trace is as below .

CustDetailComponent.html:4 ERROR Error: mat-form-field must contain a MatFormFieldControl.
    at getMatFormFieldMissingControlError (form-field.es5.js:119)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField._validateControlChild (form-field.es5.js:771)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField.ngAfterContentInit (form-field.es5.js:453)
    at callProviderLifecycles (core.js:9553)
    at callElementProvidersLifecycles (core.js:9534)
    at callLifecycleHooksChildrenFirst (core.js:9524)
    at checkAndUpdateView (core.js:10455)
    at callViewAction (core.js:10692)
    at execComponentViewsAction (core.js:10634)
    at checkAndUpdateView (core.js:10457)

No comments:

Post a Comment

ec2-user@ec2 Permission denied