Ng2-intl - Error detecting character value values ​​statically

I understand this is a common problem, 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 tried the following and it still does not work:

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 a function or lambda with a link to an exported function

I took a look at the source and it does it (any ideas on how I can change it at the 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]
    };   } }
+4
source share
1 answer

I thought you were updating a new one ngc, and it changes the optimization, and then forRootcannot cancel the ngModuleannotation.

, . , , angular/route forRoot forChild. tsconfig 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"
}
+1

Source: https://habr.com/ru/post/1688924/


All Articles