title: Format input value in Angularjs
body: <p>I'm trying to write a directive that automatically formats a number in the <code>&lt;input&gt;</code> but the the model isn't formatted. 
  Getting it to work is fine, on load the value in the input is displayed as 1,000,000 and 1000000 in the controller, however when typing only the <code>ngModel.$parsers</code> function fires.
  The only time when the <code>ngModel.$formatters</code> fire is when the directive gets loaded and when the value is 0.</p>
  
  <p>How can I make it work on keypress(I've tried binding to keypress/keyup but it doesn't work).</p>
  
  <p>Here's my code:</p>
  
  <pre><code>angular.module('myApp.directives', []).directive('filterInput', ['$filter', function($filter) {
      return {
          restrict: 'A',
          require: 'ngModel',
          link: function(scope, element, attr, ngModel) {
  
              ngModel.$parsers.push(function fromUser(text) {
                  return parseInt(text.replace(",", ""));
              });
  
              ngModel.$formatters.push(function toUser(text) {
                  console.log($filter('number')(text));
                  return ($filter('number')(text || ''));
              });
  
          }
      };
  }]);
  </code></pre>