我想知道如何在自定义的角度库中为其他导入的模块提供配置。
export interface Config {
isDevMode: boolean;
}
@NgModule({
exports: [],
imports: [
HttpClientModule,
JwtModule.forRoot({
config: {
tokenGetter: '' // I want to provide these config dynamically through the BankModule forRoot method,
skipWhenExpired: true,
whitelistedDomains: [
// I want to provide these config dynamically through the BankModule forRoot method
],
blacklistedRoutes: [
// I want to provide these config dynamically through the BankModule forRoot method
]
}
})
]
})
export class BankModule {
static forRoot(config: Config): ModuleWithProviders {
return {
ngModule: BankModule,
providers: [
BankService,
BankAuthService,
{
provide: 'config',
useValue: config
}
]
};
}
}
我想通过BankModule类中的静态forRoot为JwtModule提供配置。