How can I display currency in Angular.js dynamically based on data per write?

I need to be able to dynamically show a currency with a value. For a fixed currency, I was able to:

<span id="currency-custom">{{amount | currency:'&#8377'}}</span>

      

But what if I wanted to change the currency based on what happened from the server? In my controller, I have:

$scope.longestRide = {
    'fromAddress': 'xxx',
    'toAddress': 'yyy',
    'mycurrency': '&#8377;',
    'cost': '238',
    'duration': '00:49:02'
    }

      

But this doesn't work:

<span id="currency-custom">{{amount | currency:mycurrency}}</span>

      

How can I display currency based on javascript data structure?

+3


source to share


1 answer


You should try using your filter inside ng-bing-html like this:



<span ng-bind-html="amount | currency:mycurrency"></span>

      

0


source







All Articles