title: angularjs - how to get in the controller the index of an item in a ng-repeat filter based on the value of one of its properties?
body: <p>I use a ng-repeat in my html file to display filtered items:</p>
  
  <pre><code>&lt;li ng-repeat="item in (filteredItems = (items | filter:query))"&gt;
    {{ item.name }}
  &lt;/a&gt;
  </code></pre>
  
  <p></li></p>
  
  <p>In the controller, I'd like to get the index of an item based on one of his property.</p>
  
  <p>Precision: I'd like to get the <strong>index in the filtered list</strong> and not in the whole list.</p>
  
  <p>Here for example, it will be the index of the item witch name is <code>some_item_7</code>. </p>
  
  <pre><code>var app = angular.module('myApp', []);
  
  app.controller('MyCtrl', ['$scope',
    function MyCtrl($scope) {
  
      $scope.query = 'some';
  
      $scope.items = 
      [
        { name: 'some_item_1' },
        { name: 'another_item_2' },
        { name: 'some_item_3' },
        { name: 'another_item_4' },
        { name: 'some_item_5' },
        { name: 'another_item_6' },
        { name: 'some_item_7' },
        { name: 'another_item_8' },
        { name: 'some_item_9' }
      ];
  
      $scope.itemNext = function (item) {
        console.log(item.name);
      };
  
      $scope.getIndexFromName = function (name) {
        console.log("trying to get the index of the item with name = " + name);
      }
  
      $scope.getIndexFromName('some_item_7');
  
    }
  ]);
  </code></pre>
  
  <p><a href="http://plnkr.co/edit/C8gL9qV1MyonTwDENO9L?p=preview" rel="nofollow">http://plnkr.co/edit/C8gL9qV1MyonTwDENO9L?p=preview</a></p>
  
  <p>Any idea ?</p>