【发布时间】:2018-07-30 02:15:22
【问题描述】:
编辑:通过使用 @angular/material 而不是 angular-material 修复。如果您不熟悉 Angular,请按照以下答案进行操作:)
我正在尝试将“MatToolbarModule”导入单个导航栏组件,以便在 Angular 项目的 navbar.component.html 中使用它,但这似乎不起作用。 在“app.module.ts”中导入模块并在 index.html 中使用它可以正常工作。
这是我的 navbar.component.ts :
import {NgModule} from '@angular/core';
import {MatToolbarModule} from 'angular-material';
@NgModule({
imports: [MatToolbarModule]
})
//Component decorator and rest of code is untouched
在我的 navbar.component.html 中:
<mat-toolbar>MyTitle</mat-toolbar>
我得到错误:“如果 'mat-toolbar' 是一个 Angular 组件,那么验证它是这个模块的一部分。”
我正在使用 angular 5 和最新版本的 angular-material 及其依赖项。 谢谢!
【问题讨论】:
-
关于材料文档导入看起来像这样 -
import {MatToolbarModule} from '@angular/material/toolbar。还是我错过了什么? -
我使用的包是 angular-material 并且相同的导入行在 app.module.ts /w index.html 中工作正常。
标签: angular