I have a module (lets say module A) that imports another module (module B), that gets parameters though its forRoot
.
@NgModule({
declarations: [AComponent, XComponent],
imports: [
BrowserModule,
ModuleB.forRoot({
apiKey: 'api-key-here',
}),
],
providers: [],
bootstrap: [AComponent],
exports: [AComponent],
})
export class ModuleA {}
ModuleA is going to be installed via npm and used in all kinds of different projects. I would like each user of ModuleA to provide his own api key that will be passed into the internal ModuleB for use.
My researched yielded that the best way is to implement a forRoot
for ModuleA, that will accept a config object containing the api key.
However, I could not find (via research or trial-and-error) how to pass that api key to the forRoot
of ModuleB.
Any advice? Thanks!