I am trying to use the currency pipe in angular to display a whole number price, I don't need it to add .00 to my number, the thing is, its not formatting it according to my instructions. here is my HTML:
<h5 class="price"><span>{{billingInfo.amount | currency:billingInfo.currencyCode:'1.0-0'}}</span> {{billingInfo.period}}</h5>
here is my ts:
ngOnInit() { this.billingInfo = {amount: 100, currencyCode: 'USD', period: 'Hour'}; }
and here is the output:
$100.00 Hour
things I tried to do:
1.use the decimal number pipe(no good, the currency pipe turns it into a string)
2.add number formater(:1.0-0) to my currencyPipe but it seems to be ignored
what am I missing?
The display parameter can be “code” (currencycode will be displayed) or “symbol” or “symbol-narrow” or any other custom value. Few countries like Canada have two currency codes like symbol CA$ and symbol-narrow $. If the country locale does not have symbol-narrow, default symbol will be displayed.
minFractionDigits : The minimum number of digits after the decimal point. Default is 0.
To remove .00
from the currency pipe you can use this pattern. See the digitsInfo section on CurrencyPipe for more information.
{{ amount | currency : 'USD' : 'symbol' : '1.0-0' }}
If you don't need the decimal you can use the number pipe.
${{amount | number}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With