I'm struggling with a common issue and can't seem to find a solution that works.
My setup involves Angular 4.2.6 along with ng2-intl 2.0.0-rc.3.
Despite trying the following code, I am still facing issues:
export function intlFactory(http:Http) {
return new IntlStaticLoader(http, '../../locale', '.json');
}
@NgModule({
imports: [
IntlModule.forRoot({
provide: IntlLoader,
useFactory: intlFactory,
deps: [Http]
})
]
});
The error message I receive is:
"Function calls are not supported, consider replacing the function or lambda with a reference to an exported function"
After looking at the source code, I noticed this pattern (any suggestions on how to modify it in a forked version?):
export class IntlModule {
static forRoot(providedLoader: any = {
provide: IntlLoader,
useFactory: i18nLoaderFactory,
deps: [Http] }): ModuleWithProviders {
return {
ngModule: IntlModule,
providers: [providedLoader, IntlService]
}; } }