我有一個懶加載模塊,需要使用一個組件。我已經將它添加到應用程序模塊聲明中,並期望這應該使聲明的組件應用程序範圍更廣。延遲加載模塊如何繼承應用程序模塊聲明?
儘管Angular無法識別延遲加載的模塊中的組件。我試着將它添加到兩個模塊聲明中,然後得到一個警告,要求在app.module
和lazyLoaded.module
之上的更高模塊中添加聲明。
例如(nameOfModule/Component
)
Error: Type (DeclareMeComponent) is part of the declarations of 2 modules: (AppModule) and (LazyLoadedModule)! Please consider moving (DeclareMeComponent) to a higher module that imports AppModule and (LazyLoadedModule). You can also create a new NgModule that exports and includes (DeclareMeComponent) then import that NgModule in (AppModule) and (DeclareMeComponent).
什麼是高比app.module
?我怎樣才能得到延遲加載模塊繼承/使用聲明的組件連同應用模塊?
創建共享模塊的最後一句話意味着進口。 https://angular.io/guide/ngmodule#shared-modules – echonax
好的,謝謝你的建議 – Jonathan002