Convert number to words using AngularJS

Convert number to words using AngularJS

In this Post We Will Explain About is Convert number to words using AngularJS With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to convert number to words in AngularJS Example

In this post we will show you Best way to implement Changing Number to Words in AngularJS, hear for convert number to words in indian rupees in AngularJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.




Getting Started for convert number to words using AngularJS

We have used CDN(libes) for AngularJS so you must need Your internet Data connection for them to work on convert number to words using AngularJS.

Also Read :   jquery password strength Checker using regular expression

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js"></script>

index.html

This is the main HTML view of our Simple Web Application. In here, we have init Base declared all our simple my this Example(convert number to words using AngularJS) dependencies and the HTML Elements that we have created.

<div ng-app="app">
  <input type="text" ng-model="name" /> {{name | words}}
</div>

index.js

This contains our simple custom index.js files Add Like as javascript, Angularjs scripts

var liveApp = angular.module('liveApp',[]);

liveApp.filter('words', function() {
  function isInteger(query) {
        return query % 1 === 0;
    }

  
  return function(value) {
    if (value && isInteger(value))
      return  covertWords(value);
    
    return value;
  };

});


var livethos = ['','thousand','million', 'billion','trillion'];
var livedang = ['zero','one','two','three','four', 'five','six','seven','eight','nine']; 
var livetenth = ['ten','eleven','twelve','thirteen', 'fourteen','fifteen','sixteen', 'seventeen','eighteen','nineteen'];
var livetvew = ['twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety']; 


function covertWords(s)
{  
    s = s.toString(); 
    s = s.replace(/[\, ]/g,''); 
    if (s != parseFloat(s)) return 'not a number'; 
    var query = s.indexOf('.'); 
    if (query == -1) query = s.length; 
    if (query > 15) return 'too big'; 
    var n = s.split(''); 
    var str = ''; 
    var mjk = 0; 
    for (var ld=0; ld < query; ld++) 
    {
        if ((query-ld)%3==2) 
        {
            if (n[ld] == '1') 
            {
                str += livetenth[Number(n[ld+1])] + ' '; 
                ld++; 
                mjk=1;
            }
            else if (n[ld]!=0) 
            {
                str += livetvew[n[ld]-2] + ' ';
                mjk=1;
            }
        }
        else if (n[ld]!=0) 
        {
            str += livedang[n[ld]] +' '; 
            if ((query-ld)%3==0) str += 'hundred ';
            mjk=1;
        }


        if ((query-ld)%3==1)
        {
            if (mjk) str += livethos[(query-ld-1)/3] + ' ';
            mjk=0;
        }
    }
    if (query != s.length)
    {
        var dv = s.length; 
        str += 'point '; 
        for (var ld=query+1; ld<dv; ld++) str += livedang[n[ld]] +' ';
    }
    return str.replace(/\s+/g,' ');
}

window.covertWords = covertWords;

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Also Read :   simple angularjs hello world example





Example

I hope you have Got What is Convert digits into words with AngularJS And how it works.I would Like to have FeedBack From My Blog(live24u.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(live24u.com) Are Most Always Welcome.