【问题标题】:Drag and Drop list, angularjs拖放列表,angularjs
【发布时间】:2014-05-26 20:48:38
【问题描述】:

我需要一个带角度的拖放列表,但我也需要 $scope.list 更改,因为我必须将新订单存储在我的数据库中。

我找到了this answer,我用它得到了这个http://jsfiddle.net/aras7/9sueU/1/

var myapp = angular.module('myapp', ['ui']);

myapp.controller('controller', function ($scope) {
    $scope.list = ["one", "two", "three", "four", "five", "six"];
});

angular.bootstrap(document, ['myapp']);

问题是当我尝试从上到下更改元素时,一个位置不起作用。

例如,将“一”降低一个位置以得到“二”、“一”、“三”、“四”,......第二个列表也应该改变,但它没有。

two
one
three
five
four
six
----------
one
two
three
five
four
six

两个列表应该相等。

【问题讨论】:

标签: jquery angularjs list jquery-ui drag-and-drop


【解决方案1】:

要让 ui-sortable 正常工作,您需要添加 sortable.js 并像这样使用 ui.sortable 启动模块

var myapp = angular.module('myapp', ['ui.sortable']);//add .sortable

myapp.controller('controller', function ($scope) {
    $scope.list = ["one", "two", "three", "four", "five", "six"];
});

angular.bootstrap(document, ['myapp']);    

http://jsfiddle.net/9sueU/3/

【讨论】:

  • 是否有任何选项可以保留拖放功能但删除可排序的功能?我的意思是,只允许在不同列表之间拖放?
  • 它有一个选项sort: false 可以禁用排序功能。
猜你喜欢
  • 2014-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-14
  • 2013-06-28
  • 2014-06-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多