title: Angular JS: $index like parameter of a filter
body: <p>i want to pass the variable $index like parameter of a filter. The code is the next:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div ng-app='myApp' ng-controller="Main" &gt;
      &lt;div ng-repeat="i in (filtered = (elements | myFilter: $index))" &gt;
  
          &lt;ul&gt;
              &lt;il ng-repeat="i in filtered"&gt;{{i.T}}&lt;/il&gt;
          &lt;/ul&gt;
  
  
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>var myApp = angular.module('myApp', [])
  .filter("myFilter", function(){
      return function(input, index){
          var newArray = [];
          for(var x = 0; x &lt; input.length; x+=2){
               newArray.push(input[index]);   
          }
          return newArray;
      }
  });
  
  
  function Main($scope){
      $scope.elements = [
          { T: 't1', V: "v1"},
          { T: 't2', V: "v2"},
          { T: 't3', V: "v3"},
          { T: 't4', V: "v4"},
          { T: 't5', V: "v5"}
      ];
  } 
  </code></pre>
  
  <p>I have proved if i pass a number like parameter, it is working. But when i pass the variable $index the code isn`t working. </p>
  
  <p>Is there anyway to pass the variable $index or the index of the ng-repeat like a parameter in a filter?</p>
  
  <p>Greetings.</p>
  
  <p>Edit:</p>
  
  <p>Really, I want to show something like that:</p>
  
  <p>...
  t1t2
  t3t4
  t5
  ...
  or in HTML:</p>
  
  <p>...</p>
  
  <pre><code>&lt;div&gt;
      &lt;ul&gt;
         &lt;il&gt;t1&lt;/il&gt;
         &lt;il&gt;t2&lt;/il&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;ul&gt;
         &lt;il&gt;t3&lt;/il&gt;
         &lt;il&gt;t4&lt;/il&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;ul&gt;
         &lt;il&gt;t5&lt;/il&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>