From http://www.yearofmoo.com/2012/10/more-angularjs-magic-to-supercharge-your-webapp.html