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

查看:156
本文介绍了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>

如果您使用 npm bower 所有语言环境都可通过 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天全站免登陆