Reputation: 945
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.
Upvotes: 1
Views: 742
Reputation: 2450
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);
Upvotes: 2