When trying to compile my RC6 app using the following command:
ngc -p C:\Path\To\Project
(I am placed inside C:\Path\To\Project\node_modules\.bin
when I'm running the command)
I get the following error:
Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 20:25 in the original .ts file), resolving symbol CoreModule in C:/Path/To/Project/app/modules/core/core.module.ts
This is what it complains about:
@NgModule({
imports: [
CommonModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, 'app/languages', '.json'),
deps: [Http]
})
],
If I remove TranslateModule.forRoot...
the error disappears.
How do I replace this with an exported function as the error implies?
you have to update ng2-translate to >5.0.0 first of all. I had the same issue on version ~2.5.0 and exported function did not help.
So your steps:
export function translateStaticLoaderFactory(http: Http) { return new TranslateStaticLoader(http, 'app/languages', '.json'); }
@NgModule({ imports: [ CommonModule, TranslateModule.forRoot({ provide: TranslateLoader, useFactory: translateStaticLoaderFactory, deps: [Http] }) ],