1

I need to use AngularJS currency filter {{value | currency }}, but I dont want to include the whole library only for that. Is there any way to use that filter only directly on html or JavaScript?

Thanks in advance.

1
  • Are you asking how to implement the angular currency filter so that you don't have to include angular? Commented Nov 10, 2014 at 4:14

1 Answer 1

2

In your html:

{{ currency_expression | currency : symbol : fractionSize}}

In your javascript angular controller:

$filter('currency')(array, expression)

Without controller, you can use $injector to get $filter:

var $injector = angular.injector(['ng']);
$filter = $injector.get("$filter");
var result = $filter('currency')(array, expression);
Sign up to request clarification or add additional context in comments.

Comments

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.