Created
October 29, 2014 18:47
-
-
Save pedrorocha-net/9aa21d5f34d9cc15d18f to your computer and use it in GitHub Desktop.
Angular JS Filter for Number Abbreviation
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
"use strict" | |
@Application = angular.module("numberAbbrevFilter", []) | |
@Application.filter "numberAbbrev", -> | |
(number) -> | |
if number >= 10000000 | |
return (number / 1000000).toFixed(0) + 'M' | |
if number >= 1000000 | |
return (number / 1000000).toFixed(1) + 'M' | |
if number >= 10000 | |
return (number / 1000).toFixed(0) + 'K' | |
if number >= 1000 | |
return (number / 1000).toFixed(1) + 'K' | |
return number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment