title: Confused When Filter is evaluate In angularJS
body: <p><strong>FIlter In Template</strong></p>
  
  <p><strong>Using a filter in a view template will reevaluate the filter on every digest</strong> From angular document.</p>
  
  <p>Even when the value of expression is not changing still it is reevaluating(or say input to filter is not changing). What i know  for each expression some watcher will be set. During digest loop it will check for any change in expression value if yes than it will fire watcher. And expression will be reevaluate.But why filter is reevaluate on every digest even when input is not changing.</p>
  
  <p><strong>The filter function should be a pure function, which means that it should be stateless and idempotent. Angular relies on these properties and executes the filter only when the inputs to the function change.</strong>
  From angular doc.</p>
  
  <p>Earlier it say it will revaluate on every digest in second bold text they say whenever input change.What is the diffference between two. 
  <a href="https://docs.angularjs.org/guide/filter" rel="nofollow">https://docs.angularjs.org/guide/filter</a></p>
  
  <p><strong>Update</strong></p>
  
  <p>I made reveraFilter</p>
  
  <p>app.js File</p>
  
  <pre><code>angular.module('todoApp')
      .filter('reversa', function() {
          return function(input, condition) {
              input = input || '';
              var out = '';
              for (var i = 0; i &lt; input.length; i++) {
                  out = input.charAt(i) + out;
              }
              return out;
          };
      })
      .controller('MainCtrl', function($scope, reversaFilter) {
  
  
          $scope.todo = '';
          $scope.text = 'shriyansh';
          //  $scope.text = reversaFilter($scope.text);
  
  
      });
  </code></pre>
  
  <p>Partial HTML</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;h2&gt;My todos&lt;/h2&gt;
      &lt;input type="text" ng-model="todo"&gt;
      &lt;div&gt;{{text|reversa}}&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I put breakpoint inside return functon of filter.
  When ever I am changing value of todo variable it is execution filter code also. But I put filter to text not to todo.</p>