我需要为 angular 2 中的每个模块添加一个插件吗?
Do i need to add a plugin to every module in angular 2?
我正在使用 ng-bootstrap
和 angular 2。我将它导入到我的 app.module
中并且工作正常。
我正在延迟加载另一个模块,ng-bootstrap
组件无法在其中工作。如果我在延迟加载模块中再次导入 ng-bootstrap 模块,它们就会工作。
我的问题是:我是否需要在我编写的每个模块中再次导入第 3 方模块,或者有某种方法可以通过某些设置使它们工作?
PS: 我是angular 2
的新手
您必须在要使用导入模块的组件、指令或管道的任何模块中导入模块。没办法了。
What you can do is to create a module that exports several other modules (like for example the `BrowserModule` that exports `CommonModule`.
@NgModule({
declarations: [CoolComponent, CoolDirective, CoolPipe],
imports: [MySharedModule1, MySharedModule2],
exports: [MySharedModule1, MySharedModule2, CoolComponent, CoolDirective, CoolPipe],
})
export class AllInOneModule {}
@NgModule({
imports: [AllInOneModule]
})
class MyModule {}
这样您就可以让 AllInOneModule
导出的所有内容都可供 MyModule
使用。
我正在使用 ng-bootstrap
和 angular 2。我将它导入到我的 app.module
中并且工作正常。
我正在延迟加载另一个模块,ng-bootstrap
组件无法在其中工作。如果我在延迟加载模块中再次导入 ng-bootstrap 模块,它们就会工作。
我的问题是:我是否需要在我编写的每个模块中再次导入第 3 方模块,或者有某种方法可以通过某些设置使它们工作?
PS: 我是angular 2
的新手您必须在要使用导入模块的组件、指令或管道的任何模块中导入模块。没办法了。
What you can do is to create a module that exports several other modules (like for example the `BrowserModule` that exports `CommonModule`.
@NgModule({
declarations: [CoolComponent, CoolDirective, CoolPipe],
imports: [MySharedModule1, MySharedModule2],
exports: [MySharedModule1, MySharedModule2, CoolComponent, CoolDirective, CoolPipe],
})
export class AllInOneModule {}
@NgModule({
imports: [AllInOneModule]
})
class MyModule {}
这样您就可以让 AllInOneModule
导出的所有内容都可供 MyModule
使用。