title: INR currency format in AngularJs in input type = text fields
body: <p>How to display number in INR format in textbox (input type=text).
  So when user keeps changing the text it should accordingly format to INR format.</p>
  
  <p>Below code works if we bind ng-model.</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>var app = angular.module('app', []);
  
  app.controller('indexCtrl', function ($scope) {
      $scope.amount = 12564252.33;
  });
  
  app.filter('INR', function () {        
      return function (input) {
          if (! isNaN(input)) {
          
              var result = input.toString().split('.');
  
              var lastThree = result[0].substring(result[0].length - 3);
              var otherNumbers = result[0].substring(0, result[0].length - 3);
              if (otherNumbers != '')
                  lastThree = ',' + lastThree;
              var output = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
              
              if (result.length &gt; 1) {
                  output += "." + result[1];
              }            
  
              return output;
          }
      }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app="app"&gt;
  &lt;head&gt;    
      &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-controller="indexCtrl"&gt;
      Input: &lt;input type="text" ng-model="amount"&gt;
      &lt;h3&gt;{{amount | INR}}&lt;/h3&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>basically i want the input field itself should be comma separated as soon as user is typing.</p>