Created
March 20, 2015 18:55
-
-
Save bbrown/d0ddc5f1a5d16013c63f to your computer and use it in GitHub Desktop.
Angular filter to convert a big number into a smaller one
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
angular.module("hedge").filter("ensmallenNumber", function() | |
{ | |
return function(number) | |
{ | |
var billion = 1000000000; | |
var million = 1000000; | |
if (number >= billion) | |
{ | |
return number / billion + "B"; | |
} | |
if (number >= million) | |
{ | |
return number / million + "MM"; | |
} | |
return number; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment