Created
February 7, 2014 21:53
-
-
Save builtbylane/8872732 to your computer and use it in GitHub Desktop.
Angular Filter: Title Case
This file contains hidden or 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
/** | |
* Description: | |
* simple title case => Simple Title Case | |
* Usage: | |
* {{some_text | titleCase}} | |
*/ | |
app.filter('titleCase', function () { | |
return function (input) { | |
var words = input.split(' '); | |
for (var i = 0; i < words.length; i++) { | |
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1); | |
} | |
return words.join(' '); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// with prepositions intact