Smit Patel
Smit Patel

Reputation: 109

Get last inner ng-repeat index

    <div ng-repeat="post in vm.post track by $index">
          <button ng-click="vm.remove(post,$index)"></button>
          <div ng-repeat="comment in post.cmt track by comment._id">
               <div ng-repeat="reply in comment track by reply._id">
                    <button ng-click="vm.remove(post,'what shoud I pass here as index')"></button>
        </div>
     </div>
</div>
   vm.remove = function() {
   if (isConfirm) {
       groupFactory.updateGroupMember(data).then(function(response) {
           SweetAlert.swal('Deleted!', response.data.message);
           vm.post.splice(index, 1);
       }, function(error) {
           $scope.showError(error.data.message);
       });
   }
 }

How do I get current index in last inner ng-repeat of reply like I got in vm.remove() for post

Upvotes: 2

Views: 61

Answers (1)

Adrian
Adrian

Reputation: 8597

Just use $index as that will give you the current ng-repeat index. You can get the parents ng-repeats index using $parent.$index too, if needed.

Upvotes: 3

Related Questions