带逗号的角货币格式化程序 [英] Angular Currency Formatter with Comma

查看:85
本文介绍了带逗号的角货币格式化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下语法将欧元金额格式化为角度

I am using following syntax to format euro amount in angular

{{ 20,00 | currency : "€" : 2}}

产生什么

"20.00€""

"20.00€"

是否有任何简单的方法来格式化(使用此语法)以逗号代替点的欧元价格.就像

Is there any simple way to format (using this syntax) the Euro price with comma instead of dot. so like

"20,00€"

"20,00€"

?

https://docs.angularjs.org/api/ng/filter/currency

推荐答案

对于本地化,角度杠杆利用i18n进行应用程序的本地化和全局化.使用欧元符号不会给您逗号和句点之间的格式.

For localisation angular leverages i18n for localization and gloablization of applications. Using the euro symbol will not give you the formatting of comma vs. period.

https://docs.angularjs.org/guide/i18n

您需要通过在项目中包括正确的i18n脚本来包括格式.如果您的应用程序需要德语格式,这是来自角度的示例.

You'll need to include the formatting by including the correct i18n script in your project. Here's the example from angular if your application needs german formatting.

<html ng-app>
 <head>
….
   <script src="angular.js"></script>
   <script src="i18n/angular-locale_de-de.js"></script>
….
 </head>
</html>

但是,如果您需要根据货币符号设置货币格式,则需要实现自定义过滤器.

If you need to format your currency based upon the symbol for the currency though, you'll need to implement a custom filter.

这篇关于带逗号的角货币格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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