Skip to content
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

Md Form Field is not working #6948

Closed
davenlin19 opened this issue Sep 8, 2017 · 6 comments
Closed

Md Form Field is not working #6948

davenlin19 opened this issue Sep 8, 2017 · 6 comments

Comments

@davenlin19
Copy link

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 !

@donroyco
Copy link
Contributor

donroyco commented Sep 8, 2017

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

@davenlin19
Copy link
Author

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.

@davenlin19
Copy link
Author

davenlin19 commented Sep 8, 2017

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

@donroyco
Copy link
Contributor

donroyco commented Sep 8, 2017

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.

@davenlin19
Copy link
Author

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

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants