1

Is there a way to get a currency symbol from currency pipe? I have this piece of code in template:

{{ '' | currency : 'symbol' }}

But this shows nothing.

Note: I don't want to use getCurrencySymbol method, because I want to use what currency pipe provides.

Update

Unlike How to hide currency symbol in angular currency pipe, I'was asking about how to show only the currency symbol. And found different solution than currency pipe - I would like to share it.

Frimlik
  • 357
  • 3
  • 15

1 Answers1

0

If you just want the symbol, you could use the slice pipe to get the first character e.g.

{{ 0 | currency | slice:0:1 }}
// $

There is also a utility function getCurrencySymbol - which is probably used internally by the currency pipe

import { getCurrencySymbol } from '@angular/common';

getCurrencySymbol('GBP', 'narrow'); // £
Drenai
  • 11,315
  • 9
  • 48
  • 82