Components: Md Form Field is not working

Created on 8 Sep 2017  路  6Comments  路  Source: angular/components

I have an error:
md-form-field must contain a MdFormFieldControl. Did you forget to add mdInput to the native input or textarea element?

This is my current html:
<form [formGroup]="form" *ngIf="form">
<md-form-field>
<input mdInput placeholder="title" name="title" formControlName="title">
</md-form-field>
</form>

and the version of my material:
"@angular/material": "^2.0.0-beta.10"

Thanks !

Most helpful comment

Sorry i don't know why but my plunker works: http://plnkr.co/edit/LjSqMOVm9xAo01QCBTAn?p=streamer

In fact, i think i know why i had this error, i didn't import the MdInputModule. Now, i import it, also the BrowserAnimationsModule. I have a normal input with no style at all.

All 6 comments

Please use the issue template and provide a Plunker to reproduce the issue.

Sorry i don't know why but my plunker works: http://plnkr.co/edit/LjSqMOVm9xAo01QCBTAn?p=streamer

In fact, i think i know why i had this error, i didn't import the MdInputModule. Now, i import it, also the BrowserAnimationsModule. I have a normal input with no style at all.

Do you think i'm missing some modules to be imported ? Thanks !

As stated in the Material documents for Input, you have to import MdInputModule as import {MdInputModule} from '@angular/material';. That could have solved your issue.

I found the problem, i thought that the style has been imported automatically. But in fact, i have to import the theme manuelly in my scss. And now it works.

Thank you

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings