我创建了一个Authentication Angular Library项目,以抽象化我正在使用的提供程序。由于有角度的库项目不支持环境配置,因此我正在寻找一种使消耗型应用程序项目能够将配置传递给库项目的方法。我见过有人建议为该库的模块实现forRoot
方法,但是我不确定如何在Authentication模块的NgModule
装饰器中使用该方法。例如:
@NgModule({
imports: [
ProviderAuthModule.initAuth({
issuer: config.issuer,
redirectUri: `${config.rootURI}/implicit/callback`,
clientId: config.clientID,
responseType: config.responseType
})
],
declarations: [],
exports: []
})
export class TdAuthenticationModule {
static forRoot(config: ?) {
return {
ngModule: TdAuthenticationModule,
?
};
}
}
我看过一些使用InjectorToken
的人的例子,他们能够将配置传递给图书馆项目,然后可以将其注入该图书馆的服务和组件中,但是我不知道是否存在一种使用传递给该模块的装饰器中的库模块中内容的方法。
这可能吗?