I have an application that deals with different currencies. I get currency symbol from a web service and store that symbol in the controller's $scope.
$scope.symbol = '€';
When I try to show that in html,
This is working:
{{ 1500 | currency:"€" }}
This is not working
{{ 1500 | currency:symbol }}
here's a plunker. Any ideas?
If using JQuery (Otherwise do the same thing but in pure javascript, it will take much more code but is possible, basically create a html dom element and insert your input as innerHTML to it, then read it's innerText)
And then of course
If you want to bind html or markup you need to use "ng-bind-html" and mark the content as trusted on your controller. I'm unaware of any way of how to do this with the mustache binding mechanism. But this is the approach we've been using when needing to bind markup.
Below are 3 options available to you:
Controller
Markup
Working sample
Try this in your controller:
Plunker
to an addition to Rohan's answer, where ng-bind-html was the solution, you could also use isoCurrency module.
if you have the ISO 4217 currency code (3 chars length e.g. USD, EUR, etc) isoCurrency can output the right format, fraction size and symbol.
To display currency symbol in angular js you need provide HTML entity for currency symbols below are the examples and usage in through code and in template :
Inside your Template example of Euro:
example of Rupee:
Also check below url
http://www.cs.tut.fi/~jkorpela/html/euro.html
From controller :
Inject $filter in your controller