I need to have a module that does instantiate another one with a custom variable like the following.
// app.module.ts
MyServiceModule.forRoot({
custom: 'customVar'
})
Then within the myServiceModule
I try to do the following
#NgModule({
imports: [
anotherServiceModule.forRoot({
custom: // <-- The 'customVar' from MyServiceModule
})
]
})
export class MyServiceModule {
static forRoot(config: {custom: string}) {
return {
ngModule: MyServiceModule,
providers: [
{
provide: MyServiceProvider,
useValue: config,
}
]
}
}
}
Can I somehow use the instance of my MyServiceProvider
?
Edit
Also, I'm not the owner of anotherServiceModule
Objectif
I did build an extended language service because the ngx-translate was missing some feature that my specific project did required.
I would like to initiate this library with prefix given in the forRoot()
Real life example
MyServiceModule.forRoot({
custom: ['/assets/i18n']
})
@NgModule({
imports: [
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [
HttpClient,
custom // <-- The 'customVar' from MyServiceModule
],
},
}),
]
}),
// ...