Steve Hougom
asked on
Problem with angular currency pipe
I am using the angular currency pipe and it keeps formatting my input incorrectly.
For example I enter 12303 and its formatting it as $12,303.00 when i really wanted 123.03
Here is my line of code in typescript: this.formattedAmount = this.currencyPipe.transform(temp, 'USD');
Hope someone can help.
For example I enter 12303 and its formatting it as $12,303.00 when i really wanted 123.03
Here is my line of code in typescript: this.formattedAmount = this.currencyPipe.transform(temp, 'USD');
Hope someone can help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
If you don't want the currency in the output why are you using the Currency pipe?
If your issue is that you are giving it cents and it is assuming you are giving it dollars then the answer is - don't give it cents.
Also interested to know why you are doing this in code - the currency pipe produces a string typically for output and is usually used in the view
If your issue is that you are giving it cents and it is assuming you are giving it dollars then the answer is - don't give it cents.
Also interested to know why you are doing this in code - the currency pipe produces a string typically for output and is usually used in the view
{{myPrice | currency:'USD'}}
If you want to convert from cents then{{myPrice / 100 | currency:'USD'}}
You have accepted an answer that is non-angular - while you can do it this way, Angular provides specific mechanisms for working with currencies. You should consider using those.
@Julian,
he said :
he said :
when i really wanted 123.03
@leakim
<span>{{currencyValue | currency:" "}}</span>
> 123.56
Open in new window