angular – md-form-field必须包含MdFormFieldControl

前端之家收集整理的这篇文章主要介绍了angular – md-form-field必须包含MdFormFieldControl前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用angular-material2在我的组件中插入输入字段.这是我的 HTML

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

在控制台中,我收到此错误但我不明白为什么我收到错误

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

解决方法

首先,您需要在app.module中导入MdFormFieldModule,MdInputModule模块.然后,您需要在< input>中添加mdInput指令.

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

链接working demo.

猜你在找的Angularjs相关文章