如何在 angular js 中获取特定的货币符号(在我的例子中是卢比符号)而不是默认的货币符号(美元符号) [英] How to get specific currency symbol(rupee symbol in my case) in angular js instead of the default one (dollar $ symbol)

查看:29
本文介绍了如何在 angular js 中获取特定的货币符号(在我的例子中是卢比符号)而不是默认的货币符号(美元符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 angular js 中使用货币"时,我得到一个美元符号.如何根据要求获取所需的货币符号.好像现在我需要知道如何使用货币显示卢比符号.如果有人可以解释如何在不同需求的时候将这种货币用于不同的符号,那将非常有用.

When i use 'currency' in angular js, I am getting a dollar symbol. How to get required currency symbols based on the requirements. As if now i need to know how to display a rupee symbol using currency. It will be of great use if anyone could explain how to make use of this currency for different symbols at the times of different requirements.

示例:

Item Price<span style="font-weight:bold;">{{item.price | currency}}</span>

如果我的 item.price 是 200.这里显示的是 200$.我需要显示卢比符号而不是美元.

If my item.price is 200. Here it shows 200$. I need to display rupee symbol instead of dollar.

推荐答案

要在 angular js 中显示货币符号,您需要为货币符号提供 HTML 实体,下面是直通代码和模板中的示例和用法:

To display currency symbol in angular js you need provide HTML entity for currency symbols below are the examples and usage in through code and in template :

在您的欧元模板示例中:

Inside your Template example of Euro:

Item Price<span style="font-weight:bold;">{{price | currency:"&euro;"}}</span>

卢比示例:

Item Price<span style="font-weight:bold;">{{price | currency:"&#8377;"}}</span>

还要检查下面的网址

http://www.cs.tut.fi/~jkorpela/html/euro.html

来自控制器:

在你的控制器中注入 $filter

Inject $filter in your controller

$scope.price=$filter('currency')($scope.price,'&euro;')

这篇关于如何在 angular js 中获取特定的货币符号(在我的例子中是卢比符号)而不是默认的货币符号(美元符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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