The md-form field must contain an MdFormFieldControl

I am trying to insert an input field into my component using angular-material2 . This is my HTML:

 <md-form-field> <input type="text"> </md-form-field> 

In the console, I get this error, but I don’t understand why I get the error:

Field

md-form should contain an MdFormFieldControl. Have you forgotten to add mdInput to your own input or textarea element?

+5
source share
1 answer

First you need to import the MdFormFieldModule,MdInputModule into your app.module. Then you need to add the mdInput directive to <input> .

 <md-form-field> <input type="text" mdInput> </md-form-field> 

Link to a working demo .

+10
source

Source: https://habr.com/ru/post/1271540/


All Articles