Created
June 22, 2013 01:01
-
-
Save juanpujol/5835379 to your computer and use it in GitHub Desktop.
AngularJS Filter to transform a constant like strings to human text. i.e. "SUPPORT_SYSTEM" => "Support system"
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('app').filter('humanizeConstant', function(){ | |
return function(text) { | |
if(text) { | |
var string = text.split("_").join(" ").toLowerCase(); | |
var string = string.charAt(0).toUpperCase() + string.slice(1); | |
return string | |
}; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I needed to capitalize the first letter in each word so I did this: