The following code shows how to create a custom capitalize filter.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!-- ww w . j a v a2 s . c o m-->
<body ng-app="app">
<span>{{ "this is some text" | capitalize }}</span>
<script type='text/javascript'>
var app = angular.module('app', []);
app.filter('capitalize', function() {
return function(input, param) {
return input.substring(0,1).toUpperCase()+input.substring(1);
}
});
</script>
</body>
</html>
The code above is rendered as follows: