Javascript – removing an element from array

I’m displaying elements from an arraylist in table on the webpage. I want to make sure that once the user press “delete the data”, the element in the table is immediately removed so the user does not have to refresh and wait to see the new table. So I’m currently doing it by removing the element from the arraylist, below is the code:

$scope.list= function(Id) {
        var position = $scope.list.indexOf(fooCollection.findElementById({Id:Id}));

        if (position>-1) {

But I the position is always -1, so the last item is always removed from the list no matter which element I delte.

Can someone help me with this? Thank you so much!

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.