13

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?

Sinandro
  • 2,426
  • 3
  • 21
  • 36

4 Answers4

36

Just send the arguments empty:

price | currency:'':''
JuanF
  • 756
  • 1
  • 6
  • 12
16

As @R.Richards mentioned, I ended up using the number pipe:

{{ 50000 | number }} <!-- output: 50,000 -->
Sinandro
  • 2,426
  • 3
  • 21
  • 36
2

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 -->
JJon Hsieh
  • 21
  • 2
0

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 --> 
tbdrz
  • 1,811
  • 2
  • 12
  • 30