Created
September 22, 2014 18:29
-
-
Save gerisztein/d21f016630957cc20d43 to your computer and use it in GitHub Desktop.
Capitalize filter for AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
angular.module('capitalize', []) | |
.filter('capitalize', function() { | |
return function(str) { | |
return (!!str) ? str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\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