android - Ionic 2 RC0 和 Angular 2 最新构建 android 错误 (ngc : Error: Error encountered resolving symbol values statically)

标签 android angular typescript compilation ionic2

使用ionic build android命令构建android时出现错误

ngc:错误:静态解析符号值时遇到错误。引用本地(非导出)符号“字典”。考虑导出符号(原.ts文件中14:8位置),解析符号TRANSLATION_PROVIDERS

我的代码在translation.ts文件中

export const TRANSLATIONS = new OpaqueToken('translations');
// all traslations
 const dictionary : any = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_AR_NAME]: LANG_AR_TRANS,
    [LANG_FR_NAME]: LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS : any = [
    { provide: TRANSLATIONS, useValue: dictionary},
];

我的 app.module.ts 代码

import {TRANSLATION_PROVIDERS,TranslatePipe,TranslateService} from './translate';

@NgModule({
  declarations: [
    MyApp,
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,

  ],
  providers: [TRANSLATION_PROVIDERS,TranslateService ]
})
export class AppModule {}

关于这个问题的任何建议,顺便说一下,当我使用 ionic serve 命令时,我的项目 100% 使用事务处理

最佳答案

我找到了解决方法。

您不必导出字典对象,只需将键更改为静态值即可。

这对我有用:

// all translations
const dictionary = {
  "en": LANG_EN_TRANS,
  "ar": LANG_AR_TRANS,
  "fr": LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS = [
  { provide: TRANSLATIONS, useValue: dictionary },
];

关于android - Ionic 2 RC0 和 Angular 2 最新构建 android 错误 (ngc : Error: Error encountered resolving symbol values statically),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40001256/

相关文章:

javascript - 使用 Fluent API 增强 Typescript

android - 在安卓手机上实时进行语音处理

Angular 4示例教程类型脚本错误

angular - 在 Angular2 中禁用应用程序加载/路由

dependency-injection - 依赖注入(inject) : Angular 2 not working

arrays - Typescript - 降序排列字符串

android - rawQuery 在 SQLite android 中不起作用

android - adb shell ping 主机不工作

android - 我的 CountDownTimer 中的文本转语音有什么问题?

Angular 2 PrimeNG Scheduler onDrop事件获取日期