title: Accessing ng-repeat index value from custom directive
body: <p><strong>Hello,</strong></p>
  
  <p>I have made a custom html directive using AngularJS to plot data that I get from a HTTP request.</p>
  
  <p>I've run into an issue where I can't access the $index property of ng-repeat to select the relevant data sets in the returned data to plot. </p>
  
  <p><strong>My code looks like this:</strong></p>
  
  <pre><code>&lt;div ng-controller="AppCtrl"&gt;
      &lt;form class="sidebar" ng-submit="getData()"&gt;
           //some selection method
           &lt;button type="submit"&gt;Select&lt;/button&gt;
  
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;chart ng-if="data" ng-repeat="item in data" id="{{ $index }}" val="data"&gt;&lt;/kpi-chart&gt;
  </code></pre>
  
  <p>getData() returns an object array called <em>"data"</em> containing the measurements I'm interested in plotting in a nested object. </p>
  
  <pre><code>app.directive('chart',  function () {
  //setup of initial object
      return {
      restrict: 'EA',
      terminal: true,
      scope: {
          val: '='
      },
      link: function (scope, element, attrs) {
  
          // Setup of SVG object on page
  
          var orig = newVal[$index];
  </code></pre>
  
  <p>I want this orig, here at the end, to refer to the <strong>$index</strong> from ng-repeat above to make it plot graphs with the correct data, with a 1 graph to 1 data set ratio. </p>
  
  <p>How can I make the ng-repeat $index value avaliable to the directive so that it knows which data set to access?</p>