Created
November 16, 2015 14:56
-
-
Save lgrayland/adef049279fd0b78f91c to your computer and use it in GitHub Desktop.
filter to capitalise first character use capitalize:true to set first letter of each word
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
.filter('capitalize', function() { | |
return function(input, all) { | |
var reg = (all) ? /([^\W_]+[^\s-]*) */g : /([^\W_]+[^\s-]*)/; | |
return (!!input) ? input.replace(reg, 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