title: angularjs data transformation
body: <p>I have an input field that displays some information:</p>
  
  <pre><code>&lt;input type="text" id="1" data-transformer="" data-ng-model="number"/&gt;
  </code></pre>
  
  <p>What I need is to change displayed information according to some variable for example:</p>
  
  <p>"number" model is equal to value of 10. And I also have dynamic variable "x" which ranges 0-24. The condition would be: if "x > 23" then instead of original "number" model value 10, I need to display "--".</p>
  
  <p>I thought this would be possible using additional directive "data-transformer="""  </p>
  
  <pre><code>mbg.directive('transformer', function () {
      return {
          require: 'ngModel',
          link: function (s, e, a, m) {
              m.$formatters.unshift(function (model) {
                  s.tmp = model;
                  return (s.x &gt; 23 ? '--' : model);
              });
  
              m.$parsers.push(function () {
                  return s.tmp;
              });
          }
      };
  });
  </code></pre>
  
  <p>However this doesn't work as I would like: It works only the first time, the page is loaded and "x" is set, but if "x" value changes nothing happens. I kinda understand why it is like so (it's because  transformer directive acts only when "number" model changes, and not "x").</p>
  
  <p>What I would like to know, how can I achieve result I need?</p>