Skip to content

Instantly share code, notes, and snippets.

@nelsonpecora
Created March 7, 2014 22:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonpecora/9421120 to your computer and use it in GitHub Desktop.
Save nelsonpecora/9421120 to your computer and use it in GitHub Desktop.
AngularJS currency filter - trims to 2 decimal places and adds a currency mark
app.filter('nfcurrency', [ '$filter', '$locale', function ($filter, $locale) {
var currency = $filter('currency'), formats = $locale.NUMBER_FORMATS;
return function (amount, symbol) {
var value = currency(amount, symbol);
return value.replace(new RegExp('\\' + formats.DECIMAL_SEP + '\\d{2}'), '')
}
}]);
@bpmckee
Copy link

bpmckee commented Aug 7, 2014

This doesn't round the number. If you put $4.99 through this filter, it would output $4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment