One interesting challenge I'm facing is how to hide the dependency of a shared module from the root module, while still allowing the root module to configure it through the shared module. Here's an example:
In my SharedModule.ts file:
@NgModule({
imports: [
//I want the root module to configure this without directly importing it
ConfigModule.forRoot({
provide: ConfigLoader,
useFactory: (configFactory),
deps: [HttpClient]
})
],
declarations: [MyComponent],
exports: [MyComponent],
providers: [HttpClient]
})
export class SharedModule { }
Now in my AppModule.ts file:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
SharedModule, //I need to configure ConfigModule from here
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
I've tried using ModuleWithProviders (static forRoot) but it doesn't expose imports. Any thoughts or suggestions on how to achieve this?