Ionic 2 RC0 和 Angular 2 最新的 Android 构建错误(ngc:错误:静态解析符号值时遇到错误)

2024-05-23

当我使用构建android时出现错误ionic build 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 },
];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ionic 2 RC0 和 Angular 2 最新的 Android 构建错误(ngc:错误:静态解析符号值时遇到错误) 的相关文章

随机推荐