1

Angualr JS code:

$scope.rupee = $filter('currency')($scope.dols * 67.33, 'INR', 3);

I am trying to insert html code inside this filter. That is instead of 'INR', I wish to get ₹ symbol. Please help me to solve this. And the problem is not getting the ₹ through filter. Instead of 'INR', I want to use &#8377 but it's not rendering as I expected.

html code:

<div>{{rupee}}</div>
Mr_Perfect
  • 8,254
  • 11
  • 35
  • 62
  • 1
    Possible duplicate of [HTML code for INR](http://stackoverflow.com/questions/3430242/html-code-for-inr) – Phil Jul 26 '16 at 10:59
  • I want to get the symbol from $filter. If I use ₹ in filter instead of 'INR', It's not working. Also it wouldn't work – Mr_Perfect Jul 26 '16 at 11:05

3 Answers3

2

Modify your statement to

$scope.rupee = $filter('currency')($scope.dols * 67.33, '\u20B9', 3);

As you asked, "Can we write HTML code inside symbolFormat parameter?" Answer will be below:

Currency Filter function Number Formats

It takes a string parameter, so whatever string you are providing, it will be used to apply as currency symbol

For reference you can check Here

Romesh
  • 2,291
  • 3
  • 24
  • 47
1

You can try like this:

{{ currency_expression | currency : symbol : fractionSize}}

$scope.rupee = $filter('currency')($scope.dols * 67.33, '₹', 3);

See all use cases (currency symbol & sign - in controller & directly on view):

<div ng-app ng-controller="RupeeCtrl">
    <b>From controller with sign</b><br/>
    {{rupeeSign}}
    <br/><br/>
    <b>From controller with code</b><br/>
    {{rupeeCode}}
    <br/><br/>
    <b>From view</b><br/>
    {{ price | currency:'&#8377;'}}      
</div>

function RupeeCtrl($scope, $filter) {
    $scope.price = 75.255;
    $scope.rupeeSign = $filter('currency')($scope.price, '₹', 3);
    $scope.rupeeCode = $filter('currency')($scope.price, '\u20B9', 3);
}

JSFiddle

Mixed with answer from @Romesh Jain

daan.desmedt
  • 3,752
  • 1
  • 19
  • 33
  • If I copy the symbol, it works fine. But If there is no way to get symbol by html inside filter, Why to mention an argument 'symbol' in the 'currency' filter? – Mr_Perfect Jul 26 '16 at 11:27
0

This looks like a duplicate question to this: How to get specific currency symbol(rupee symbol in my case) in angular js instead of the default one (dollar $ symbol)

Just use this ASCII code for the Rupee symbol: ₹

See the ASCII code here: http://www.fileformat.info/info/unicode/char/20b9/index.htm

Community
  • 1
  • 1
Nikolai
  • 198
  • 1
  • 14
  • No. not at all. I just want to get it through the html code inside a filter – Mr_Perfect Jul 26 '16 at 11:10
  • 1
    well why can't you use the accepted answer from the link above and do something like this: `
    {{rupeeAmount | currency:"₹"}}
    `. Why do you have to set it in the code?
    – Nikolai Jul 26 '16 at 11:14
  • This is my task to accomplish for today. Can we write html code inside filter? – Mr_Perfect Jul 26 '16 at 11:18
  • If there is no way to get symbol by html inside filter, Why to mention an argument 'symbol' in the 'currency' filter? – Mr_Perfect Jul 26 '16 at 11:22