任何人都可以向我澄清我应该如何使用.forRoot()调用构建多个嵌套的功能模块层次结构?
例如,如果我有这样的模块怎么办:
- MainModule
- SharedModule
- FeatureModuleA
- FeatureModuleA1
- FeatureModuleA2
- FeatureModuleB
Run Code Online (Sandbox Code Playgroud)
所有要素模块都具有.forRoot()静态函数.
我应该如何定义FeatureModuleA以某种方式"转移".forRoot()函数?
@NgModule({
imports: [
//- I can use .forRoot() calls here but this module not the root module
//- I don't need to import sub-modules here, FeatureA only a wrapper
//FeatureModuleA1.forRoot(), //WRONG!
//FeatureModuleA2.forRoot(), //WRONG!
],
exports: [
//I cannot use .forRoot() calls here
FeatureModuleA1,
FeatureModuleA2
]
})
class FeatureModuleA {
static forRoot(): ModuleWithProviders {
return {
//At this point I can set any …Run Code Online (Sandbox Code Playgroud)