AngularJS filter capitalize First letter of Every word

Rate this post

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 :  Capitalize First Letter JavaScript Example

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:
[php]
var liveApp = angular.module(‘liveApp’, []);
liveApp.filter(‘liveCaptila’, function() {
return function(text) {
return (!!text) ? text.charAt(0).toUpperCase() + text.substr(1).toLowerCase() : ”;
}
});
[/php]

Use Filter:
[php]

{{ Live-your-string | liveCaptila }}

[/php]

Capitalize First Letter Filter – AngularJS Example

index.html
[php]

First word only: {{comments | live_capitalize}}

All words: {{comments | live_capitalize:true}}

[/php]

index.js
[php]
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();}) : ”;
}
});

READ :  ngTouch event example using angularjs-ngtouch directive

function newliveCtrl($scope) {
$scope.comments = ‘you are most wel-come to infinityknow.com’;
}
[/php]

Example

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.

Leave a Reply

Your email address will not be published.