I realise this is a common issue, but I can't figure out an implementation that works.
I am using Angular 4.2.6 with ng2-intl 2.0.0-rc.3.
I have tried the following and it is still not working:
export function intlFactory(http:Http) {
return new IntlStaticLoader(http, '../../locale', '.json');
}
@NgModule({
imports: [
IntlModule.forRoot({
provide: IntlLoader,
useFactory: intlFactory,
deps: [Http]
})
]
});
The exception is:
Function calls are not supported, consider replacing the function or lambda with a reference to an exported function
I've taken a look at the source and it does this (any ideas on how I could change it on a fork, so that it works?)
export class IntlModule {
static forRoot(providedLoader: any = {
provide: IntlLoader,
useFactory: i18nLoaderFactory,
deps: [Http] }): ModuleWithProviders {
return {
ngModule: IntlModule,
providers: [providedLoader, IntlService]
}; } }