I created an Authentication Angular Library project to abstract the provider I'm using. Since angular library projects do not support environment configuration, I'm looking for a way for the consuming application project to be able to pass the configuration to the library project. I've seen people suggest implementing a forRoot
method for the library's module, but I'm not sure how to use that in the NgModule
decorator of the Authentication module. For example:
@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,
?
};
}
}
I've seen examples of folks using InjectorToken
and being able to pass configuration to library projects that can then be injected into that library's services and components and whatnot, but I don't understand or know if there is a way to use what's passed into the library module in the decorator for that module.
Is this possible?