報錯現象:
用modal打開某個組件頁面時報錯
報錯:No component factory found for UpdateAuthWindowComponent. Did you add it to @NgModule.entryComponents?
原因:
使用loadChild模式加載對應路由下的組件時,是懶加載模式,即需要的時候才會加載,所以如果路由走的是懶加載模式,需要的module即使在app.module中引入過了,依舊需要再引入一次
解決方案:
在app.module 的entryComponents 再導入一次
參考資料:https://blog.csdn.net/qq_34829447/article/details/89224634
延伸知識
AppModule
imports 本模塊聲明的組件模板需要的類所在的其它模塊。
providers 服務的創建者,並加入到全局服務列表中,可用於應用任何部分。
declarations 聲明本模塊中擁有的視圖類。Angular 有三種視圖類:組件、指令和管道。
exports declarations 的子集,可用於其它模塊的組件模板。
bootstrap 指定應用的主視圖(稱為根組件),它是所有其它視圖的宿主。只有根模塊才能設置 bootstrap 屬性。
參考資料:https://blog.csdn.net/it_rod/article/details/79188921
Angular入口組件(entry component)和聲明式組件的區別:
參考資料:https://majing.io/posts/10000004561171