Created
May 22, 2013 07:34
-
-
Save marufsiddiqui/5625869 to your computer and use it in GitHub Desktop.
A Sample AngularJS filter
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
var homeModule = angular.module('HomeModule', []); | |
homeModule.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
Nice simple filter that works with all caps:
Tests to go with it if you want them: