I have tried to get index like this
this is my html
<div ng-repeat="item in items" ng-click="findindex($index)"></div>
this is controller
$sceop.findinedx=function(index)
{
alert(index);
}
here i am able to get index value.but i want to get index value through directive
this is my html
<div ng-repeat="item in items" my-directive></div>
this is my directive
app.directive('myDirective',function()
{
return function(scope, elem, attrs,$index)
{
elem.bind('click', function($index)
{
alert($index);
});
});
};
here i am not able to get index..so how to get index value in directive?
$indexis bad practice. See my answer for elaboration.