在 AngularJS 中拖放可排序的 ng:repeats? [英] Drag and drop sortable ng:repeats in AngularJS?
本文介绍了在 AngularJS 中拖放可排序的 ng:repeats?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 AngularJS 中的 ng-repeat
元素上使用 jQuery.sortable
是否容易?
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?
推荐答案
Angular UI 有一个 sortable 指令,点击这里是演示
Angular UI has a sortable directive,Click Here for Demo
代码位于 ui-sortable,用法:
<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')) }
这篇关于在 AngularJS 中拖放可排序的 ng:repeats?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文