Skip to content

Instantly share code, notes, and snippets.

@dahoba
Created August 18, 2014 17:02
Show Gist options
  • Save dahoba/68119dd3831805c6c809 to your computer and use it in GitHub Desktop.
Save dahoba/68119dd3831805c6c809 to your computer and use it in GitHub Desktop.
Angularjs custom filter: Title Case
app.filter('titlecase', function() {
return function(input, scope) {
var result ='';
if (input != null && input != undefined){
var words = input.split(' ');
for(var i=0;i<words.length; i++){
result = result.concat(words[i].substring(0,1).toUpperCase() + words[i].substring(1)+' ');
}
}
return result;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment