List reordering toIndex and fromIndex both 0

I’m trying to make a reorder-able list of attributes underneath a header in a larger list. I’m not sure if I’m missing something as I’ve only been using Ionic for a week so any input would be appreciated :smile:

In my controller, I print out all of the values passed (item, $index, $fromIndex, $toIndex), and item and $index both have the right value, but both $fromIndex and $toIndex are 0 regardless of where I’m dragging it to/from.

My code is as follows:

<div class="item item-divider item-button-right">
    <button class="button button-clear button-stable button-icon" ui-sref="header">
      <i class="icon ion-ios7-arrow-right"></i>
    <ion-list ng-if="items !== undefined" ng-repeat="item in items" show-reorder="true">
      <ion-item ng-controller="itemsCtrl">
        <span style="margin-left: 50px;">{{item}}</span>
        <ion-reorder-button class="ion-navicon" on-reorder="display(item, $index, $fromIndex, $toIndex)">
1 Like

can you please provide a codepan

Sorry! Here’s a codepen. The fromIndex and toIndex are always passed as 0 regardless of the element you move and where you move it to.

your problem is that you put the ng-repeat on the ion-list insted on the ion-item
and remove the ng-controller from the ion item you dont want for each item its on controller

1 Like

Oh my goodness, thank you so much! I would’ve never have picked up on that, haha. :smile:

1 Like