Angular Library Modules从模块中导出组件,服务和其他组件 [英] Angular Library Modules export components, services and others from module
问题描述
我创建了一个Angular库。在我的图书馆中,我希望通过在其中包含功能模块来使其干净:
I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them:
示例:
Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc
GraphModule
BarGraphComponent
PieGraphComponent
我的导航模块当前如下所示:
My Navigation Module currently looks like this:
@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }
我的图书馆模块当前看起来像这样:
My Library Module currently looks like this:
@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }
我发现的大多数教程都使用的库中只包含组件,而没有其他组件(例如模块)。我确实发现使用库中的模块的教程未显示如何导出片段。
Most tutorials I am finding is using a library with only components in them and nothing else such as modules. The tutorials I do find using modules in a library do not show how to export pieces.
本质上,我想将此库导入任何应用程序并能够调用 NavigationSidebarComponent
或库或服务中某个模块中的任何其他组件。
Essentially I want to import this Library into any application and be able to call NavigationSidebarComponent
or any other component from a module in the library or service.
我将继续对此进行深入研究。
I will keep looking into this on my end.
推荐答案
您必须在 NavigationModule
> LibraryModule ,而不是 NavigationSidebarComponent
You have to export NavigationModule
in the LibraryModule
, not NavigationSidebarComponent
这篇关于Angular Library Modules从模块中导出组件,服务和其他组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!