title: Use 'filter' from the Controller in angularJS
body: <p>Please review this fiddle. I am trying to use 'filter' from the controller. I have an data array, which i want to search based on the search criteria provided in the text box attached with the button. </p>
  
  <p>User enters text and then press enters to search.
  User presses the back key on the text box the original list appears again.</p>
  
  <p>I want to apply the filter from the controller and not on my partial. So i have to work with what i have.</p>
  
  <p>Please advice.</p>
  
  <pre><code>&lt;div ng-app="myApp"&gt;
      &lt;div ng-controller="MyCtrl"&gt;
  &lt;input type='text' data-ng-model='search'&gt;
      &lt;button ng-click='newList()'&gt; &lt;/button&gt;
          &lt;table&gt; &lt;tr data-ng-repeat= "item in items"&gt;&lt;td&gt; {{item.name}}  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;    
  
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  var myApp = angular.module('myApp',[]);
  
  
  function MyCtrl($scope, $filter) {
      $scope.items= [
      {
      id: 0,
      name: "Noman",
      email: "John@email.com"},
  {
      id: 1,
      name: "Sameer",
      email: "James@email.com"},
  {
      id: 2,
      name: "Humair",
      email: "Jill@email.com"}
  ];    
  
  $scope.newList =  function () {
  $scope.items = $filter('filter')($scope.items,'name',$scope.search)
      }
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/r7KH7/66/" rel="nofollow">http://jsfiddle.net/r7KH7/66/</a></p>