我有一个加载屏幕组件,我希望在不同模块中的不同组件之间重用。Angular2在模块中导入组件
我有一个的AppModule
@NgModule ({
declarations: [
LoadingScreenComponent //has tag app-loading-screen
],
imports: [
ReportsModule,DashboardModule
]
});
export class AppModule {
}
在ReportsModule我
@NgModule ({
declarations: [
ReportsComponent
],
});
export class ReportsModule {
}
在ReportsComponent HTML文件
<app-loading-screen></app-loading-screen>
在做这种方式我得到一个错误,
'app-loading-screen' is not a known element
不同模块中的其他几个组件也需要使用加载屏幕组件。
为什么这会失败,但我已经在根模块中包含LoadingScreenComponent
。或者我该怎么办呢?
能否请您提供的LoadingScreenComponent的代码呢? –
组件只有一个文本显示正在加载。 –
创建一个共享模块并声明,导出LodingScreenModule,然后添加AppModule和ReportsModule。 – Sreemat