微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ionic 2 RC0和Angular 2最新版本在构建android时出现错误(ngc:错误:在静态解析符号值时遇到错误)

当我使用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 {}

关于这个问题的任何建议,顺便说一句,当我使用离子服务命令我的项目工作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 },
];

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐