Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
94
rated 0 times [  98] [ 4]  / answers: 1 / hits: 84346  / 13 Years ago, thu, september 8, 2011, 12:00:00

Is it at all easy to use jQuery.sortable on ng-repeat elements in AngularJS?






It would be awesome if re-ordering the items automatically propagated that ordering back into the source array. I'm afraid the two systems would fight though. Is there a better way to do this?


More From » angularjs

 Answers
43

Angular UI has a sortable directive,Click Here for Demo


Code located at ui-sortable, usage:


<ul ui-sortable ng-model="items" ui-sortable-update="sorted">
<li ng-repeat="item in items track by $index" id="{{$index}}">{{ item }}</li>
</ul>

$scope.sorted = (event, ui) => { console.log(ui.item[0].getAttribute('id')) }

[#90192] Wednesday, September 7, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deiong

Total Points: 15
Total Questions: 103
Total Answers: 99

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
deiong questions
Mon, Nov 22, 21, 00:00, 3 Years ago
Tue, Jun 15, 21, 00:00, 3 Years ago
Mon, Dec 21, 20, 00:00, 3 Years ago
Thu, Oct 15, 20, 00:00, 4 Years ago
;