Reputation: 16460
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]
}; } }
Upvotes: 4
Views: 109
Reputation: 1402
I thought you update to the new ngc
and it's change the optimize then forRoot
couldn't callback ngModule
annotation.
I got the one solution to solve similar situation but not guarantee.Despite it's the same way as angular/route
to outlet forRoot
and forChild
.Add this config to your tsconfig
for your webpack
.
tsconfig.yourbuild.ts.
"compilerOptions": {
"declaration": true,
"stripInternal": true,
"moduleResolution": "node",
"module": "es2015",
"target": "es5",
"lib": [
"es2015",
"es2017",
"dom"
],
"skipLibCheck": true,
"types": [],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"inlineSources": true,
"baseUrl": "./tmp", //set what you base on.
"rootDir": "./tmp", //set what you base on.
"outDir": "dist/"
},
"angularCompilerOptions": {
"annotationsAs": "decorators",
"annotateForClosureCompiler": false,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "router.js",
"flatModuleId": "@angular/router"
}
Upvotes: 1