Ionic 2 RC0和Angular 2构建android的最新错误(ngc:错误:静态解析符号值时遇到错误) [英] Ionic 2 RC0 And Angular 2 latest Error on Build android (ngc: Error: Error encountered resolving symbol values statically)
问题描述
错误当我使用离子构建android
命令构建android时出现
ngc:错误:解决符号时遇到错误价值静态。引用本地(非导出)符号字典。考虑导出符号(原始.ts文件中的位置14:8),解析符号TRANSLATION_PROVIDERS
我在translation.ts文件中的代码
export const TRANSLATIONS = new OpaqueToken('translations');
//所有翻译
const字典: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代码
从'./translate'导入{TRANSLATION_PROVIDERS,TranslatePipe,TranslateService};
@NgModule({
声明:[
MyApp,
],
导入:[
BrowserModule,
IonicModule。 forRoot(MyApp)
],
bootstrap:[IonicApp],
entryComponents:[
MyApp,
],
提供商:[ TRANSLATION_PROVIDERS,TranslateService]
})
导出类AppModule {}
任何建议关于这个问题,顺便说一句,当我使用 ionic serve
命令时,我的项目100%与transaltion一起工作
我找到了解决方法。
您不必导出字典对象,只需将键更改为静态值。 / p>
这对我有用:
//所有翻译
const dictionary = {
en:LANG_EN_TRANS,
ar:LANG_AR_TRANS,
fr:LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS = [
{provide:TRANSLATIONS,useValue:dictionary},
];
Error Appear when i build android using ionic build android
command
ngc: Error: Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'dictionary'. Consider exporting the symbol (position 14:8 in the original .ts file), resolving symbol TRANSLATION_PROVIDERS
My code in translation.ts file
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},
];
My app.module.ts code
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 {}
any suggestions about this issue, by the way when im using ionic serve
command my project work 100% with transaltion
I found a workaround for that.
you don't have to export your dictionary object, just change the keys to static values.
This worked for me:
// 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 },
];
这篇关于Ionic 2 RC0和Angular 2构建android的最新错误(ngc:错误:静态解析符号值时遇到错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!