Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created March 20, 2015 18:54
Show Gist options
  • Save bbrown/2001cfc45b6162f73046 to your computer and use it in GitHub Desktop.
Save bbrown/2001cfc45b6162f73046 to your computer and use it in GitHub Desktop.
Angular filter to format a percentage
angular.module("app").filter("percentage", ["$filter", function($filter)
{
return function(input, decimals, alreadyConverted)
{
var number = (alreadyConverted) ? input : input * 100;
return $filter("number")(number, decimals) + "%";
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment