1

I'm using Angular2.Dart and I need to render currency symbols inside table cells. I have all the hex codes available for all the currencies I need to be able to display as strings in a Currency class:

class Currency {
...
    symbol = "&#x24 ;" //Space is just there so it doesn't parse to $ for this example
...

So, in the template I want to do something like <td>{{myCurrency.symbol}}</td>, and have that display the $, however its not the case as simply the string value is being displayed without any parsing, $#x24;. How can I get the hex code to parse correctly and display the corresponding currency symbol?

Thanks a million.

I should also mention I have tried to use the CurrencyPipe, however some of the more odd currencies, for example "Ghana Cedi", code="GHS", symbol="¢" with the CurrencyPipe, {{12.1 | currency:'GHS':true}} displays GHS12.1. I want to be able to display all the currency symbols correctly.

Jan Vladimir Mostert
  • 12,380
  • 15
  • 80
  • 137
ndv
  • 23
  • 1
  • 4
  • You can use hex value directly if you just print the symbol in the td right? check this https://docs.angularjs.org/api/ng/filter/currency – Hema Nandagopal Jul 06 '17 at 14:47
  • From that I gathered I should be able to do something like {{12.1 | currency:$}} which works fine. The issue is again once I try get the hex value from an object which is storing it as a string. then it just displays the entire string and doesn't parse the hex. Additionally, I'm only looking to display the currency symbol alone at this point. The currency pipe isn't very happy with me when I try to not give it a number value to format. – ndv Jul 06 '17 at 15:00
  • 2
    Potentially related to this question? https://stackoverflow.com/questions/34585453/how-to-bind-raw-html-in-angular2 – Jan Vladimir Mostert Jul 06 '17 at 19:21
  • 1
    Thanks, that worked. Helps when you know exactly what you're looking for. Appreciate the help! – ndv Jul 07 '17 at 07:14

0 Answers0