I found some examples of module\'s forRoot() method like the one below:
export class CoreModule {
constructor(
@Optional()
@SkipSelf()
parentModule: CoreModu
Use InjectionToken
to register the parameters with the injector. Then use DI passing in the InjectionToken
with the deps
property as follows:
export const Params= new InjectionToken('params');
...
static forRoot(someParameters?:string[]): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
{ provide: Params, useValue: someParameters },
{ provide: AnProvider1, useClass: AnProvider1, deps:[Params] },
AnProvider2
]
};
In your component constructor, use the InjectionToken
:
constructor(@Inject(Params) someParameters: string[])