0

When I am using filter the index of the element is changing when i delete an element it is deleting another element how to get the exact $index of the element?

 <div class="repeater" ng-repeat="student in students | filter : query">
 <button type="button" class="close pull-right" ng-click="remove($index)">&times;</button>
 $scope.remove = function(id){
     $scope.students.splice(id,1);
 };

1 Answer 1

3

Better to use the student object itself.

<button type="button" class="close pull-right" ng-click="remove(student)">&times;</button>



$scope.remove = function(student){
     $scope.students.splice($scope.students.indexOf(student),1);
 };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.