使用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/