-1

I need to create a module with a composite of submodules that represents minimum required imports for my package to work. This composite of modules depends on external config, and i want to compile submodules dynamically without taking care about his internal configuration.

Example:

@NgModule({
  imports: [
    MyModule.forRoot({module1Config: 'something'})
  ],
})
export class AppModule { }
@NgModule({
  imports: [
    Module1
  ],
})
export class MyModule {
 static forRoot(someParam?: any) {
    if(someParam.module1Config) {
      compile(Module1.forRoot(someParam.module1Config));
    }
  }
 }

I've tried deprecated compiler.compileAsyncModule, ngCreateModule. But not working. Thanks.

1 Answers1

0

There is a way to do that but is very complex. Use lazyloading and add routerOutlet to attach a module to it, but you have to do many tricks, like name outlet dynamically to autogenerate router outlets. Very bad, because a module doesn't need to have a visual representation with a component.