List move item duplicating / overwriting

I have a really random issue with an ion-list When moving an item it replaces the item in the indexTo position.

This video demonstrates best.

My code is:

$scope.moveItem = function(exercise, fromIndex, toIndex) {

      console.log(exercise);

      $scope.exercises.splice(fromIndex, 1);
      $scope.exercises.splice(toIndex, 0, exercise);

      console.log($scope.exercises);
};

The object structure of exercise is:

 {
        "exerciseDescription": "Stand on one leg and straighten",
        "exerciseName": "Pistol Squats",
        "images": [
            248,
            250
        ]
    }

Anyone seen this before?

Any ideas @mhartington? I believe this was ok before upgrading to Angular 1.3?

Hmm, do you have a codepen example of this?

Yep:

See the Pen PqZybN by Simon Taylor (@Taylorsuk) on CodePen.

Data structure issue?

Adding some logging

$scope.moveItem = function(exercise, fromIndex, toIndex) {
  console.log('moving from ' + angular.toJson(fromIndex) + ' to ' + toIndex);

shows that fromIndex is actually an exercise object. That’s because you’re passing an extra exercises argument:

moveItem(exercises,exercise, $fromIndex, $toIndex)

Sorry thats my bad… I have corrected this and it works in the pen - i still get exactly the same as in the video at the top of this post.

Odd, works fine for me in both Chrome and Firefox.

Yeah the codepen is working fine - I am unable to recreate my issue in codpen… :frowning: