How to Capitalize the first letter of word Using filter in AngularJS?

Today now in this post i would like to share with you How to Capitalize the first letter of word Using filter in AngularJS. Sometimes, we need to covert Capitalize string on our AngularJS project then we must need to create a filter because AngularJS is not provide us any predefined function that can Capitalize word or string.

However, we can solve this problem by making our own filter that will help us to make capitalize any string or word.

so let’s start and see the following example and use it.

Create Filter:

var app = angular.module('myApp', []);
 
app.filter('capitalizeWord', function() {
    return function(text) {
      return (!!text) ? text.charAt(0).toUpperCase() + text.substr(1).toLowerCase() : '';
    }
});

Use Filter:

<p>{{ yourWord | capitalizeWord }}</p>  

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.