如何在Angular中向右显示货币符号 [英] How to display the currency symbol to the right in Angular

查看:119
本文介绍了如何在Angular中向右显示货币符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须这样显示欧元:583 €.

I have to display Euro currency like this : 583 €.

但是使用以下代码:

{{ price | currency:'EUR':true }}

我得到€583,Angular核心中是否有任何选项可以将符号向右移动?许多欧洲国家/地区在右侧使用该符号(法国,德国,西班牙,意大利).

I get €583, is there any option in Angular core to move the symbol to right? A lot of european countries use the symbol at the right (France, Germany, Spain, Italy).

推荐答案

自Angular2 RC6版本开始,您可以直接在应用模块(提供程序)中设置默认语言环境:

Since Angular2 RC6 version you can set default locale directly in your app module (providers):

import {NgModule, LOCALE_ID} from '@angular/core';

@NgModule({
  providers: [{
      provide: LOCALE_ID,
      useValue: 'de-DE' // 'de-DE' for Germany, 'fr-FR' for France ...
    },
  ]
})

此后,货币管道应获取区域设置并将符号向右移动:

Afterwards the currency pipe should pick up the locale settings and move the symbol to right:

@Component({
  selector:"my-app",

  template:`
    <h2>Price:<h2>
     {{price|currency:'EUR':true}}
  `
})

这篇关于如何在Angular中向右显示货币符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆