Skip to content

Instantly share code, notes, and snippets.

@lgrayland
Created November 16, 2015 14:56
Show Gist options
  • Save lgrayland/adef049279fd0b78f91c to your computer and use it in GitHub Desktop.
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
.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