I'm trying to use Angular currency
pipe and I wanted to remove the currency symbol all together from the formatted number, but it seems there is no option to do that. So is there any easy way to achieve this without writing a custom pipe for it?
How to hide currency symbol in angular currency pipe
Asked Answered
As @R.Richards mentioned, I ended up using the number
pipe:
{{ 50000 | number }} <!-- output: 50,000 -->
Just send the arguments empty:
price | currency:'':''
It won't work. The number gets formatted with the dollar sign! –
Scrivenor
Thanks, this works on me. This code is only remove the currency symbol –
Chloromycetin
As @R.Richards mentioned, I ended up using the number
pipe:
{{ 50000 | number }} <!-- output: 50,000 -->
Hope this example could help.
{{ 0001234.012 | currency:' ':'symbol':'0.0-1' }} <!-- 1,234 -->
{{ 0001234.012 | currency:' ':'symbol':'0.1-1' }} <!-- 1,234.0 -->
{{ 0001234.012 | currency:' ':'symbol':'0.0-2' }} <!-- 1,234.01 -->
{{ 0001234.012 | currency:' ':'symbol':'0.2-2' }} <!-- 1,234.01 -->
{{ 123 | currency:' ':'symbol':'5.0-0' }} <!-- 00,123 -->
{{ 123 | currency:' ':'symbol':'4.0-0' }} <!-- 0,123 -->
{{ 123 | currency:' ':'symbol':'3.0-0' }} <!-- 123 -->
Another option is to set this globally:
import { DEFAULT_CURRENCY_CODE, NgModule } from '@angular/core';
@NgModule({
...
providers: [
{ provide: DEFAULT_CURRENCY_CODE, useValue: '' },
],
...
})
Example:
<div>{{ 20124.56789 | currency }}</div> <!-- output: 20,124.57 -->
© 2022 - 2024 — McMap. All rights reserved.
currency
pipe, I didn't pay attention to other pipes that would do this. Thanks. – Scrivenor