Skip to content

Instantly share code, notes, and snippets.

@neilbo
Created September 22, 2014 13:49
Show Gist options
  • Save neilbo/e94149f8d5a0c4655012 to your computer and use it in GitHub Desktop.
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
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