Created
March 25, 2015 05:21
-
-
Save rageandqq/948f721065f42a6731b4 to your computer and use it in GitHub Desktop.
AngularJS Percentage Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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