Failed to apply ng2-translate


#1

Hi,

I am trying to apply ng2-translate to my Ionic 2 project, but I hit the SyntaxError issue. I am refer to the release note https://github.com/ocombe/ng2-translate/blob/master/README.md of ng2-translate to code as below.

Here is my code:

import {TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
import {Http} from 'angular2/http';
import {provide} from 'angular2/core';

@App({
  templateUrl: 'build/app.html',
  config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
  providers: [
    provide(TranslateLoader, {
      useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
      deps: [Http]
    }),
    TranslateService
  ]
})

When I deploy the project, the exception throws

ERROR in ./app/app.js
Module build failed: SyntaxError: C:/Projects/apps/myapp/app/app.js: Unexpected token (15:23)
providers: [
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, ‘assets/i18n’, ‘.json’),
deps: [Http]
}),
TranslateService
at Parser.pp.raise (C:\Projects\apps\myapp\node_modules\babylon\index.js:1378:13)

Can somebody advise what is my code problem?


#2

Hi, did you find a way to correct the syntax error ?


#3

Hi,

Yes. I fixed it after upgrade the angular2 version.

Detail refer to here