加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 2 Error在静态解析符号值时遇到错误

发布时间:2020-12-17 08:47:05 所属栏目:安全 来源:网络整理
导读:我从 this example开始在Angular2中使用简单的TranslationModule.现在,在更新了angular-cli之后,我得到了上面提到的错误,但我不知道我必须在这里更改: import {NgModule} from "@angular/core";import {TranslatePipe} from "./translate.pipe";import {TRA
我从 this example开始在Angular2中使用简单的TranslationModule.现在,在更新了angular-cli之后,我得到了上面提到的错误,但我不知道我必须在这里更改:
import {NgModule} from "@angular/core";
import {TranslatePipe} from "./translate.pipe";
import {TRANSLATION_PROVIDERS} from "./translations";
import {TranslateService} from "./translate.service";

@NgModule({
  declarations: [
    TranslatePipe
  ],providers: [
    TRANSLATION_PROVIDERS,TranslateService
  ],exports: [
    TranslatePipe
  ]
})
export class TranslateModule {
}

而翻译.ts

import {OpaqueToken} from '@angular/core';

// import translations
import {LANG_EN_US_NAME,LANG_EN_US_TRANS} from './lang-en_US';
import {LANG_DE_DE_NAME,LANG_DE_DE_TRANS} from './lang-de_DE';

// translation token
export const TRANSLATIONS = new OpaqueToken('translations');

// default language
export const DEFAULT_LANG = "en_US";

// all translations
export const dictionary = {
  [LANG_EN_US_NAME]: LANG_EN_US_TRANS,[LANG_DE_DE_NAME]: LANG_DE_DE_TRANS
};

// providers
export const TRANSLATION_PROVIDERS = [
  {provide: TRANSLATIONS,useValue: dictionary}
];
尝试将键更改为静态值,如:
export const dictionary = {
  'en': LANG_EN_US_TRANS,'de': LANG_DE_DE_TRANS
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读