我有一個加載屏幕組件,我希望在不同模塊中的不同組件之間重用。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