title: How to access AngularJS directives element index
body: <p>Is there a way to get the index of an directive element in AngularJS? I didn't found anything via the AngularJS documentation and Google. For example I have several directive elements in my DOM like: </p>
  
  <pre><code>&lt;div directive&gt;&lt;/div&gt;
  &lt;div directive&gt;&lt;/div&gt;
  &lt;div directive&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Each of them has a unique offsetTop. And I want to write these offsets into a scope variable identified with its index: </p>
  
  <pre><code>app.controller('AppController', [ '$scope', function ($scope) {
  
      $scope.offsetTopValues = [];
  
  }]);
  
  app.directive('directive', function ($window) {
  
      return function($scope, element, attrs) {
  
          $scope.offsetTopValues[index] = element[0].offsetTop;
      };
  });
  </code></pre>
  
  <p>Thanks in advance :)</p>