Skip to content

Instantly share code, notes, and snippets.

@rageandqq
Created March 25, 2015 05:21
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 rageandqq/948f721065f42a6731b4 to your computer and use it in GitHub Desktop.
Save rageandqq/948f721065f42a6731b4 to your computer and use it in GitHub Desktop.
AngularJS Percentage Filter
//take in decimal b/w 0 and 1, display as face value (b/w 0 and 100%) with a specified # decimal places
angular.module('myModule', []).filter('percentage', ['$filter', function($filter) {
return function(input, decimalPlaces) {
return $filter('number')(100 * input, decimals) + '%';
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment