title: convert amount in words in angularjs
body: <p>I need to convert amount in words. For example, the amount I will get it from service is 9876, I need to display in a table "Nine Thousand Eight Hundred and Seventy Six" in a table. </p>
  
  <p>I need to do this using angularjs. Please help me how can I do this.</p>
  
  <p><a href="https://jsfiddle.net/lesson8/5tt7d3e6/" rel="nofollow noreferrer">JSFIDDLE</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function convertNumberToWords(amount) {
      var words = new Array();
      words[0] = '';
      words[1] = 'One';
      words[2] = 'Two';
      words[3] = 'Three';
      words[4] = 'Four';
      words[5] = 'Five';
      words[6] = 'Six';
      words[7] = 'Seven';
      words[8] = 'Eight';
      words[9] = 'Nine';
      words[10] = 'Ten';
      words[11] = 'Eleven';
      words[12] = 'Twelve';
      words[13] = 'Thirteen';
      words[14] = 'Fourteen';
      words[15] = 'Fifteen';
      words[16] = 'Sixteen';
      words[17] = 'Seventeen';
      words[18] = 'Eighteen';
      words[19] = 'Nineteen';
      words[20] = 'Twenty';
      words[30] = 'Thirty';
      words[40] = 'Forty';
      words[50] = 'Fifty';
      words[60] = 'Sixty';
      words[70] = 'Seventy';
      words[80] = 'Eighty';
      words[90] = 'Ninety';
      amount = amount.toString();
      var atemp = amount.split(".");
      var number = atemp[0].split(",").join("");
      var n_length = number.length;
      var words_string = "";
      if (n_length &lt;= 9) {
          var n_array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0);
          var received_n_array = new Array();
          for (var i = 0; i &lt; n_length; i++) {
              received_n_array[i] = number.substr(i, 1);
          }
          for (var i = 9 - n_length, j = 0; i &lt; 9; i++, j++) {
              n_array[i] = received_n_array[j];
          }
          for (var i = 0, j = 1; i &lt; 9; i++, j++) {
              if (i == 0 || i == 2 || i == 4 || i == 7) {
                  if (n_array[i] == 1) {
                      n_array[j] = 10 + parseInt(n_array[j]);
                      n_array[i] = 0;
                  }
              }
          }
          value = "";
          for (var i = 0; i &lt; 9; i++) {
              if (i == 0 || i == 2 || i == 4 || i == 7) {
                  value = n_array[i] * 10;
              } else {
                  value = n_array[i];
              }
              if (value != 0) {
                  words_string += words[value] + " ";
              }
              if ((i == 1 &amp;&amp; value != 0) || (i == 0 &amp;&amp; value != 0 &amp;&amp; n_array[i + 1] == 0)) {
                  words_string += "Crores ";
              }
              if ((i == 3 &amp;&amp; value != 0) || (i == 2 &amp;&amp; value != 0 &amp;&amp; n_array[i + 1] == 0)) {
                  words_string += "Lakhs ";
              }
              if ((i == 5 &amp;&amp; value != 0) || (i == 4 &amp;&amp; value != 0 &amp;&amp; n_array[i + 1] == 0)) {
                  words_string += "Thousand ";
              }
              if (i == 6 &amp;&amp; value != 0 &amp;&amp; (n_array[i + 1] != 0 &amp;&amp; n_array[i + 2] != 0)) {
                  words_string += "Hundred and ";
              } else if (i == 6 &amp;&amp; value != 0) {
                  words_string += "Hundred ";
              }
          }
          words_string = words_string.split("  ").join(" ");
      }
      return words_string;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" name="number" placeholder="Number OR Amount" onkeyup="word.innerHTML=convertNumberToWords(this.value)" /&gt;
  &lt;div id="word"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I refered this javascript fiddle. But I want to it in a angularjs. </p>