Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: currency pipe - currency symbol without number [duplicate]

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.

like image 334
Frimlik Avatar asked Sep 05 '25 03:09

Frimlik


1 Answers

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'); // £
like image 176
Drenai Avatar answered Sep 07 '25 21:09

Drenai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!