Skip to content

Instantly share code, notes, and snippets.

@rabbishuki
Last active December 31, 2017 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabbishuki/b2c2e88ee21df8b9ca2b36fc10ea4ce3 to your computer and use it in GitHub Desktop.
Save rabbishuki/b2c2e88ee21df8b9ca2b36fc10ea4ce3 to your computer and use it in GitHub Desktop.
An AngularJS filter to format negative numbers with the currency filter.
app.filter('customCurrency', function ($filter) {
return function(amount, currencySymbol){
var currency = $filter('currency');
if(amount.charAt(0) === "-"){
return currency(amount, currencySymbol)
.replace("(", "-")
.replace(")", "");
}
return currency(amount, currencySymbol);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment