0

I have some salary information that I want to display in the format: $55k

Using the CurrencyPipe I display:

{{salary | currency:'USD'}}

This will show as

$55,000.00

Can you use the CurrencyPipe to display in 'k', with 1 decimal point if necessary.

Eg. $55340 will display as $55.3k

Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73
  • You need to write a custom pipe to replace thousands with K – Edison Augusthy Jun 09 '19 at 10:33
  • Here's a similar pipe for displaying file sizes in MB you could copy to write your own. https://ultimatecourses.com/blog/angular-pipes-custom-pipes – DavidC Jun 09 '19 at 10:33
  • You can see what's supported functionality [in the docs](https://angular.io/api/common/CurrencyPipe); for anything else, you'll have to extend it yourself. – jonrsharpe Jun 09 '19 at 10:33

1 Answers1

1

I just came across how to do this. You use digitInfo like so:

{{(salary/1000) | currency:'USD': 'symbol':'1.0-1'}}k

Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73