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
  • 32,059
  • 8
  • 70
  • 84
Alan Yong
  • 993
  • 2
  • 12
  • 25

0 Answers0