Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created December 13, 2013 02:49
Show Gist options
  • Select an option

  • Save aaronpowell/7939159 to your computer and use it in GitHub Desktop.

Select an option

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

kevox commented Jun 24, 2014

Copy link
Copy Markdown

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