Last active
December 31, 2017 12:03
-
-
Save rabbishuki/b2c2e88ee21df8b9ca2b36fc10ea4ce3 to your computer and use it in GitHub Desktop.
An AngularJS filter to format negative numbers with the currency filter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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