Angular Js 货币,后为欧元符号 [英] Angular Js currency, symbol euro after

查看:30
本文介绍了Angular Js 货币,后为欧元符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将符号欧元从值的前面移到后面?

How to move the symbol euro from the front of the value to after it?

示例:

{{product.price |货币 : "€"}} 将产生 € 12.00

但我想要12.00 €

推荐答案

您不必破解货币过滤器!

AngularJS 对 i18n/l10n 有很好的支持.货币过滤器使用来自区域设置服务的默认货币符号,并根据区域设置对其进行定位.

AngularJS has a great support for i18n/l10n. The currency filter uses the default currency symbol from the locale service and positions it based on the locale settings.

所以这一切都是为了支持和设置正确的语言环境.

So it's all about supporting and setting the right locale.

<script src="i18n/angular-locale_de-de.js"></script>

如果您使用 npmbower,所有区域设置都可以通过 angular-i18n .

If you are using npm or bower all locales are available via the angular-i18n package.

<span>{{ product.price | currency }}</span>

现在将产生以下输出:

65,95 €

支持多种本地化

如果您想支持多种本地化,请注意货币符号,因为它会更改为所用语言环境的默认货币.但是 65,95 €$65,95 不同.提供货币符号作为参数以确保安全:

If you want to support multiple localizations be careful with the currency symbol as it changes to the default currency of the used locale. But 65,95 € are different to $65,95. Provide the currency symbol as parameter to be safe:

<span>{{ product.price | currency:'€' }}</span>

de-de 中,输出仍然是 65,95 € 但如果位置是例如.en-us 将是 €65.95(尽管有其他说法 以英文显示欧元价格的正确格式).

In de-de the output would still be 65,95 € but if the location is eg. en-us it would be €65.95 (which is despite some other sayings the correct format to display euro prices in English).

要了解有关 angular 和 i18n/l10n 的更多信息,请参阅开发者指南.

To learn more about angular and i18n/l10n refer to the developer guide.

这篇关于Angular Js 货币,后为欧元符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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