[Solved] angularjs remove array specific element dosen’t work


indexOf works for array not for Object. It returns -1, and so always take the last element.

Try this:

    $scope.removeFromList = function (p) {

        var index = $scope.data2.map(function(e) { return e.ID;}).indexOf(p.ID);

         if(index >= 0)
                $scope.data2.splice(index, 1);
   }

0

solved angularjs remove array specific element dosen’t work