Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

orderBy problem #472

Closed
insmark opened this issue Jul 12, 2016 · 1 comment
Closed

orderBy problem #472

insmark opened this issue Jul 12, 2016 · 1 comment

Comments

@insmark
Copy link

insmark commented Jul 12, 2016

I added orderBy to Connected sortables demo, then drag the last item from the left to right, it will move the second last item to the right, not the last item that I wanted to move.

<div class="app" ng-repeat="app in rawScreens[0] | orderBy: 'title'">{{$index}} {{app.title}}</div>

Here the demo

@thgreasi
Copy link
Contributor

This issue again... Duplicate of #70, #113, #122, #172, ...
The reason is that your ng-model is different than the array used by the ng-repeat (fair enough, since you are ordering just the ng-repeat).

README states:

Filters that manipulate the model (like filter, orderBy, limitTo,...) should be applied in the controller instead of the ng-repeat (refer to the provided examples).
This is the preferred way since it:

  • is performance wise better
  • reduces the chance of code duplication
  • is suggested by the angularJS team
  • it does not break the matching of the generated DOM elements and the ng-model's items

Have you checked the two ordering examples (also found in README)?
As I have asked earlier in this repo:

how people expect the original (non filtered/ordered) model to be updated, after sorting a modified/sorted sub-model of that??? I really can't find an example.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants