Created
September 22, 2014 13:49
-
-
Save neilbo/e94149f8d5a0c4655012 to your computer and use it in GitHub Desktop.
Angular Comes with upper and lower case directives, so here's a capitalise directive
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
angular.module('myApp'). | |
filter('capitalise', function() { | |
return function(input) { | |
return (!!input) ? input.replace(/([^\W_]+[^\s-]*) */g, function(txt) { | |
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); | |
}) : ''; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment