Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Angular filter to replace camelCase string with Capitalized String
(function(angular) {
// 'camelCaseName' | camelCaseToCapitalized => 'Camel Case Name'
var camelCaseToCapitalizedFilter = function() {
return function(string) {
return string
.replace(/([A-Z])/g, ' $1')
.replace(/^./, function(str) {
return str.toUpperCase();
});
};
};
angular.module('camelCaseToCapitalizedFilter', [])
.filter('camelCaseToCapitalized', camelCaseToCapitalizedFilter);
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.