angularjs - $index is not working inside of ng-repeat -
i have following ng-repeat html code:
<group ng-repeat="group in groups" groups="groups" group="group"></group>
which works great me @ generating groups object. problem having $index though doesn't work inside of directive.
so in group template:
<div> {{$index}} - {{group.name}} {{group.target}} </div>
the $index undefined.
here directive:
app.directive('group', function () { return { restrict: 'e', scope: { groups: '=', group: '=' }, templateurl: '../../content/templates/recruitinggroups/group.html', link: function (scope, el) { //set rules if (scope.group.rule) { scope.rulerules = scope.group.rule.rules; } } } });
your directive uses isolate scope. access $index
inside parent scope need use $parent
:
<div> {{$parent.$index}} - {{group.name}} {{group.target}} </div>
Comments
Post a Comment