<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
Just use $index
as that will give you the current ng-repeat
index. You can get the parents ng-repeat
s index using $parent.$index
too, if needed.