Issues with list reorder


I am new to ionic and codePen. I’m trying to create a list with a reorder and delete buttons. The delete works fine, but the reorder doesn’t work well. When I debug it in chrome, I get two events, in the first one always the fromIndex and toIndex are equal, and in the second event they have some other index, but not the index of the item I am trying to change its place.
For sure I am doing something wrong.
I hope I’m sharing correctly my codePen example.

See the Pen ionic list by Nir Dweck (@ndweck) on CodePen.


So after a quick look, it seems like your reorder function is correct.

Take a look at how our demos are setup


I built my code after looking on your example. At the beginning it worked fine but then something broke and I just can’t see it.


I found the problem.
It seems that if I take the inner item with the header row and the list I want to reorder, out of the external list, it works fine.
I guess the $toIndx and $fromIndex get mixed up between the two lists.
See attached codepen for working example:

See the Pen ionic list - reorder working by Nir Dweck (@ndweck) on CodePen.