Created
October 8, 2014 13:20
-
-
Save neilbo/e1c30861fd7d33d753d5 to your computer and use it in GitHub Desktop.
remove decimals in currency
This file contains hidden or 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('noFractionCurrency', | |
[ '$filter', '$locale', function(filter, locale) { | |
var currencyFilter = filter('currency'); | |
var formats = locale.NUMBER_FORMATS; | |
return function(amount, currencySymbol) { | |
var value = currencyFilter(amount, currencySymbol); | |
var sep = value.indexOf(formats.DECIMAL_SEP); | |
console.log(amount, value); | |
if(amount >= 0) { | |
return value.substring(0, sep); | |
} | |
return value.substring(0, sep) + ')'; | |
}; | |
} ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment