-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: mat-form-field, forgot to add matInput even though it's added. #7704
Comments
That stackblitz seems to be working just fine. |
@Grundell Looks like it could be a dependency problem since the latest version of Angular Material requires |
I am seeing the same issue on my builds. All of my dependencies are up to date and on the correct version. The error only occurs when the site first loads, on the first page. It doesn't happen on any other pages that use the exact same input code block. EDIT Our issue was something different. We had an *ngIf statement on our mat-select that was not on our mat-input-container so our mat-select was rendering after the mat-input-container causing the bug to occur. So this was my error, not Material 2's error. Thanks everyone :) |
Hi! I had the exact same issue and just stumbled upon a solution. I had forgotten to import MatInputModule (Only imported MatFormFieldModule). I don't know if that is the case for you but it might be worth double checking... |
@Chan4077 - Tried to update Angular and it worked so i assume that resolved the problem. Thank you everyone for the help! |
For me, the problem was that I still had the mdInput directive on the input element, instead of the new matInput directive. See the angular docs about this error:
|
FYI: Have been seeing similar behaviour on Angular Using this component element as an example: <mat-form-field>
<mat-select required [(ngModel)]="condition.comparison" placeholder="Comparison" *ngIf="condition.argument_class !== ''">
<mat-option *ngFor="let op of comp_options" [value]="op.id">{{ op.value }}</mat-option>
</mat-select>
</mat-form-field> When this component is loaded with a model containing data, it works. If a new component is created with an empty model initialized with zero-length strings, the error occurs. Removing the ngIf directive fixes the issue. Stacktrace in Chrome:
|
I had the same problem and importing MatInputModule sorted for me! |
I had the same problem of @stevenmcountryman, I was using |
See #7737 for being able to swap inputs within a form-field. |
|
I had the same problem, the fix for me is |
@FredvanRijswijk Thank you! |
@FredvanRijswijk Thanks!! |
@FredvanRijswijk Thank you! |
@FredvanRijswijk Thank you, dank je! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug:
ERROR, "Error: mat-form-field must contain a MatFormFieldControl. Did you forget to add matInput to the native input or textarea element?"
What is the expected behavior?
What is the current behavior?
What are the steps to reproduce?
See the link below for error.
https://stackblitz.com/edit/angular-yn5zec
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
The text was updated successfully, but these errors were encountered: