Angular: $index as directive attr

http://angularjs.org/

by jonva

HTML

<div ng-controller="MyCtrl">
  <ul>
   <li my-directive index="{{$last}}" ng-repeat="value in values" class="span2">
   </li>
</ul>
</div>

JavaScript

var myApp = angular.module('myApp', []);

myApp.directive('myDirective', function() {
    return {
        replace: true,
        // transclude: true,
        scope: {
            index: '@'
        },
        template: '<div>testing {{index}}</div>',
        link: function(scope, element, attrs) {
            // ...
        }
    }
});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
    $scope.values = [1, 2, 3];
}