0

Is there a way to remove the commas when using Currency pipe?

<div>{{balance | currency }}</div>

Output like this - $7,885,412.00

I want like this - $7885412.00

NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
Dimuthu
  • 417
  • 4
  • 12

2 Answers2

4

You can use Angular Inbuilt replace pipe.

<div> {{balance | currency | replace:',':''}}</div>
mkHun
  • 5,891
  • 8
  • 38
  • 85
0

So, i just made a test app that worked.

generate a pipe using cli, as that will register it for you too with:

ng g p noComma

inside the no-comma.pipe.ts

replace the transform section with:

transform(value: number): string {
    if (value !== undefined && value !== null) {
      return value.toString().replace(/,/g, '');
    } else {
      return '';
    }
  }

then in your view,

{{ balance | currency | noComma }}
Stevep
  • 1