0

I use ng-repeat, I did the unshift which adds a new item into a list. but I have problem with deleting an item.

this is console.log($scope.postItem)

enter image description here

and I tried this:

var itemsLength = $scope.postItem.length;

for(var i = 0; i < itemsLength; i++){
 if($scope.postItem[i].post_id == get_post_id){
  $scope.postItem.splice(i,1);
  break;
  }
 }

it doesn't work because it removed the entire thing. I should be getting the index of the founded $scope.postItem[i] before splice.

Ilan Frumer
  • 31,391
  • 8
  • 68
  • 82
Alan Yong
  • 851
  • 1
  • 10
  • 24

0 Answers0