I don't get to delete the ion-item of the ion-list


#1

Hi!
In my code, the ion-delete-button runs an animation when it is pushed. After 600ms, the item must be deleted with the function:

setTimeout(function(){$scope.items.splice($scope.items.indexOf(item), 1)},600);

The problem: this item isn’t deleted after this time. But if I push the ion-delete-item of other item, the item that I previously push is deleted, but not the item that I actually push.

If I execute the $scope.items.splice($scope.items.indexOf(item), 1) without the SetTimeout, its works perfectly. But then the animation no runs…

Anybody knows how resolve this problem?

Thanks in advance

Code:

HTML

  <ion-item ng-repeat="item in items" type="item-text-wrap" ng-init="animation='new-item'" ng-class="animation">
    {{item.porciento}}%        
       <ion-delete-button class="ion-minus-circled" ng-click="animation='removed-item';onItemDelete(item)">
      </ion-delete-button>
  </ion-item>

CONTROLER

$scope.onItemDelete = function(item){
//600ms is the duration of the css animation
setTimeout(function(){$scope.items.splice($scope.items.indexOf(item), 1)},600);
}