(using angularjs 1.3) Inside an ng-repeat block, I have a custom directive that tries to identify a context based on the current item of the repeat loop, i.e. in the link function I have a line:
var context = $parse(attrs.context);
In the view, I have:
<div ng-repeat="item in items">
<div my-directive context="{{$index}}"></div>
</div>
$index is just an example, I could also have item.title. The issue here is that each time my directive link function is called, context equals 0 or whatever value related to the first iteration of the loop.
Update:
It appears that I don't need $parse. attrs.context is the value that I need. But still, it is always the same 0 value. Strangely I added this line in the link function:
var interpolation = $interpolate(attrs.context);
Believe it or not, but with this line (wherever it is in the function), each further call to the link function brings the expected value in attrs.context (0, 1, 2, ...).