我正在尝试在完全用 JavaScript ES6 编写的 Angular2/Ionic2 应用程序上实现ng2-translate管道。
但是,我在设置阶段遇到了一个步骤,我需要在 JavaScript ES6 中编写一段代码。到目前为止,我在他们的文档和互联网上发现的内容是用 TypeScript 编写的,它在尝试在我的应用程序上实现它时会引发语法错误。
编码:
@Component({
template: '<ion-nav swipeBackEnabled="true" [root]="rootPage"></ion-nav>',
config: {},
providers: [
{
//The Syntax error throws on this line, which is needed to be re-written on JS
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
},
TranslateService
],
pipes: [TranslatePipe]
})
我需要知道的是如何将用 TypeScript 编写的那段代码转换为 JavaScript ES6 以使其运行。