Can an InjectionToken be injected into a factory provider?
This is what I have implemented:
export const HOST_TOKEN = new InjectionToken<string>("host");
let configDataServiceFactory = (userService: UserService, host: string) => {
return new Config("host", 8080, userService.getUser(), userService.getPasswd());
};
export let configDataServiceProvider =
{
provide: CONFIG_API,
useFactory: configDataServiceFactory,
deps: [UserService, HOST_TOKEN]
};
In my module:
@NgModule(
providers: [
{provide: HOST_TOKEN, useValue: "allianz-host"},
configDataServiceProvider
]
)
However, Angular seems to be injecting the value "host" instead of "host-allianz" in configDataServiceProvider
.
Any suggestions on how to fix this?