Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I remove .00 if there are no cents in the amount using angular's currency filter?

Tags:

angular

budget:number=50000;
{{budget | currency:'USD':true}}

The above code displays the budget like this

$50,000.00

But I want it to display like this

$50,000
like image 691
Mubashir Avatar asked Jul 25 '17 10:07

Mubashir


2 Answers

From the Currency Pipe docs the third option uses the same format as the Decimal Pipe :digitInfo

So you can use:

{{budget | currency:'USD':'symbol':'1.0'}}

Plunker example

Edit: Jota.Toledo pointed out that you could display the cents if they're available with

{{budget | currency:'USD':true:"1.0-2"}}

Edit: Thanks to Abhay Naik for drawing attention to the v5 deprecated parameters.

like image 176
0mpurdy Avatar answered Oct 19 '22 14:10

0mpurdy


{{budget| currency : 'USD' : 'symbol' : '1.0-0' }}
like image 37
Andrew Koper Avatar answered Oct 19 '22 13:10

Andrew Koper