【发布时间】:2017-11-01 01:53:39
【问题描述】:
您好,我正在开发一个 Angular 2 项目并经常使用材料模块。由于某种原因,我什至无法将 Stepper 模块导入我的项目。所以我最终导入了整个材料模块,如下所示:
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { StepperComponent } from './stepper.component';
import { MaterialModule } from '@angular/material';
@NgModule({
imports: [CommonModule, MaterialModule],
declarations: [StepperComponent],
exports: [StepperComponent]
})
export class StepperModule {}
我在我的html中使用它来测试它的导入
<mat-horizontal-stepper></mat-horizontal-stepper>
然后我收到以下错误,
polyfills.dll.js:24743 Unhandled Promise rejection: Template parse errors:
'mat-horizontal-stepper' is not a known element:
1. If 'mat-horizontal-stepper' is an Angular component, then verify that it is part of this module.
2. If 'mat-horizontal-stepper' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<mat-horizontal-stepper></mat-horizontal-stepper>"): t@0:0 ; Zone: <root> ; Task: Promise.then ; Value:
我可以使用很多材料模块。只有这个有问题。有什么想法吗?提前致谢。
【问题讨论】:
-
发布您的 app.module.ts 代码。你在 StepperComponent 中使用
吗? -
是的,正如我的问题中提到的,我正在使用
<mat-horizontal-stepper>。与app.module.ts无关,因为StepperModule正在导入材料模块。 -
步进器组件从
2.0.0-beta.11引入,结束对MaterialModule的支持。 (您甚至阅读过更新日志吗??)