angularjsangularjs-directiveangular-filtersangular-controller

AngularJS: Currency filter not displaying symbol using code


I am trying to display currency symbol using currency code dynamically.

It's not working. It worked on my older projects. I am not sure what changed in currency filter.

This is my html

<h2>{{8.99 | currency:'USD':true}}</h2>

It should display $. But it is displaying USD.

I also tried in controller. It is not displaying $.

$filter('currency')(100, "USD", true);

Can anyone tell me what am i missing here?


Solution

  • Problem here is you are using angular syntax not angularjs syntax, just use currency filter

    DEMO

    var app = angular.module('myApp',[])
     
     
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
    <body ng-app="myApp">
     <div ng-app>
            <p> {{ 8.99 | currency }} </p>
        </div>
    </body>