Skip to content

Instantly share code, notes, and snippets.

@neilbo
Created October 8, 2014 13:20
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 neilbo/e1c30861fd7d33d753d5 to your computer and use it in GitHub Desktop.
Save neilbo/e1c30861fd7d33d753d5 to your computer and use it in GitHub Desktop.
remove decimals in currency
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