angularjsangular-dragdrop

angularjs dragdrop : filter in ng-repeat can't change the index


My source is in the plunker (click)

If I try input the keyword 'sa' in the input box and then you move the Samsung Galaxy S to the below list(target), the item moved is not that, but "iPhone" .

I tried solving this problem for 3 hours. It's very simple code. But I am a newbie in angular js, especially in angular-js-dragdrop. But I know how to solve this problem. But I can't how to solve this. The prbolem is the filter I used for quick search like the followings.

ng-repeat='item in users | filter:q'

So, wihtout filter in ng-repeat, it worked well. But, If I use this in ng-repeat, the problem is that I can't move the item that I drag. The dropped item in the target list is other one. The reason, I guess, the filter didn't change index of the changed after it is filtered. How can I solve this? Please I am looking forward to receive your help.


Solution

  • I have edited your plunk to fix it. In your options attributes to set index of dragged element do as follows:

    jqyoui-draggable="{index: users.indexOf(item) ,animate: true}"