Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created December 13, 2013 02:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronpowell/7939159 to your computer and use it in GitHub Desktop.
Save aaronpowell/7939159 to your computer and use it in GitHub Desktop.
AngularJS number directive that'll show whole numbers or round to the required number of decimal places
app.filter('numbersWithoutTrailingZero', function ($filter) {
return function (input, decimalPlaces) {
if (input % 1) {
return $filter('number')(input, decimalPlaces);
}
return $filter('number')(input, 0);
};
});
@kevox
Copy link

kevox commented Jun 24, 2014

Sorted the problem I needed to solve. Thank you!

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