2

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?

2 Answers 2

1

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> 

Sign up to request clarification or add additional context in comments.

2 Comments

It there any way to get desired result i agularjs? I mean symbol according to code.
0

Simply use currency filter:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<body style="font:15px Verdana;">
    <div ng-app>
        <p> {{ 8.99 | currency }} </p>
    </div>
</body>

Or you can also specify currency:'$' for that. Using ``currency:` will allow you to explicitly specify any symbol you want to use for that currency.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<body style="font:15px Verdana;">
    <div ng-app>
        <p> {{ 8.99 | currency:'$' }} </p>
    </div>
</body>

1 Comment

I will have currency code dynamic. I want to display symbol accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.