More

Build a filter that capitalizes each word in a string with AngularJS

By working with AngularJS we are bound to create all sorts of filters and directives on a daily basis. I was thinking it's a good idea to share some of mine every now and then. Perhaps they will save somebody time or give her/him an idea of how to solve a problem.

I created the capitalize filter for a the following use case: I had to convert uppercase strings with multiple words to lowercase strings, with capitalized words: MOUNTAIN DOOM -> Mountain Doom

CSS won't do the trick here, so JavaScript to the rescue!
The code is for an AngularJS filter, but it would work just as well if you strip out the .filter() wrapper and use it as plain JavaScript.

Grab it from github, see a quick demo here or add it as a dependency to your app using bower install ng-capitalize --save.