Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove currency symbol in AngularJS

Tags:

angularjs

Can anybody tell how to remove the currency symbol in AngularJS?

value = $filter('currency')(value);

I am getting a dollar symbol. I want to remove it.

like image 251
user386430 Avatar asked Nov 27 '22 10:11

user386430


2 Answers

I sadly don't yet have the required reputation to comment on an answer, but Samuel's answer needs a slight tweak. Just add the empty quotes, not value="".

<div> {{20 | currency:""}} </div>

Likewise you can use this same approach to override the dollar sign with any character, in this case pounds sterling:

<div> {{20 | currency:"&#163;"}} </div>

or even use the named representation rather than the decimal:

<div> {{20 | currency:"&pound"}} </div>
like image 152
Eric Soyke Avatar answered Dec 08 '22 01:12

Eric Soyke


Just pass empty string as second argument to the filter function.

value = $filter('currency')(value, "");  

Also you can inject currencyFilter itself. You do not have to derive it from the filter Factory, with that you would just do:

value = currencyFilter(value, "");

Note the syntax:

$filter('currency')(amount, symbol, fractionSize)

like image 21
PSL Avatar answered Dec 07 '22 23:12

PSL