【问题标题】:How to setup angular 2 material design 2.0.0-beta.2如何设置 Angular 2 Material Design 2.0.0-beta.2
【发布时间】:2017-03-12 20:26:46
【问题描述】:

我正在尝试使用 angular material design (2.0.0-beta2),但我无法让它工作。例如,如果我尝试使用

<md-input-container>
    <input mdInput name="value">
</md-input-container>

将以下内容添加到app.module.ts

    import {MaterialModule} from '@angular/material';

@NgModule({
    ...
    imports: [ MaterialModule, ...],
    ...
})

但我收到以下错误:

'md-input-container' is not a known element:

注意:使用上述代码的组件在我的应用程序中的某个地方存在几个模块!

当我还将MdInputContainer 添加到声明时,我得到一个不同的错误:

Type MdInputContainer is part of the declarations of 2 modules: MdInputModule and AppModule!

我想我已经接近了,但我错过了一些东西,任何帮助将不胜感激

【问题讨论】:

  • 如果你想使用来自更深模块的材料,只需将其导入该模块即可。
  • 您不需要添加声明数组。只需准确导入特定模块即可。

标签: javascript angular material-design angular-material


【解决方案1】:

为了使用角材料组件,您需要在您使用它的模块中导入MaterialModule。仅从父模块导入将无法识别。

【讨论】:

    猜你喜欢
    • 2016-09-20
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多