AngularJS filter capitalize First letter of Every word

AngularJS filter capitalize First letter of Every word

AngularJS filter capitalize First letter of Every word

In this Post We Will Explain About is AngularJS filter capitalize First letter of Every word With Example and Demo.

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Capitalize the First Letter of a String in Angularjs

In this post we will show you Best way to implement Capitalize First Letter Filter – AngularJS, hear for How to javascript – Capitalize the first letter of string in AngularJs with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  Vue js First Application Example with vue mvc

AngularJS – How to Capitalize the first letter of word Using filter

First of all the Capitalize your string as well as your specifc word. so here let’s know to following source code example and use it.

Create Filter:

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

E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

Use Filter:

<p>{{ Live-your-string | liveCaptila }}</p>  

Capitalize First Letter Filter – AngularJS Example

index.html

<div ng-app="livectrl">
  <div ng-controller="newliveCtrl">
    <input ng-model="comments" type="text" />
    <p>First word only: {{comments | live_capitalize}}</p>
    <p>All words: {{comments | live_capitalize:true}}</p>
  </div>
</div>

index.js

angular.module('livectrl', []).
  filter('live_capitalize', function() {
    return function(input, all) {
      var live_reg = (all) ? /([^\W_]+[^\s-]*) */g : /([^\W_]+[^\s-]*)/;
      return (!!input) ? input.replace(live_reg, function(parma){return parma.charAt(0).toUpperCase() + parma.substr(1).toLowerCase();}) : '';
    }
  });
 
function newliveCtrl($scope) {
  $scope.comments = 'you are most wel-come to infinityknow.com';
}

Example

READ :  Laravel Multiple Order By Columns

I hope you have Got AngularJS – How to Capitalize the first letter of word Using filter And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.