Live Demo
Why this:
# Controller
$scope.price = -10;
# View
{{ price | currency }}
results in ($10.00)
rather than
Do you mean display -$10.00 rather than ($10.00)?
The default, at least angularJs version 1.2.1 is to display with parentheses. Eg.: ($10.00)).
If so, this is my situation. I created a custom filter for that:
var app = angular.module('myApp');
app.filter('customCurrency', ["$filter", function ($filter) {
return function(amount, currencySymbol){
var currency = $filter('currency');
if(amount.charAt(0) === "-"){
return currency(amount, currencySymbol).replace("(", "-").replace(")", "");
}
return currency(amount, currencySymbol);
};
}]);
So it delegates to the built-in currency filter and "decorates" or "un-decorates" the parentheses.
I couldn't find a way to change $LocaleProvider on the fly. If someone knows please let me know.
cheers Leonardo Correa