在AngularJS移动卡中拖放Directiv

Bar*_*lis 9 drag-and-drop angularjs

我使用这个方向:http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types

我有移动卡的问题,当我移动卡更高是好的,如果卡提供较少的问题开始.

我做了这个功能:

if ($scope.movingItem.indeksList == index) {
        console.log('qrwa')
        $scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard +1, 1);
        $scope.lists[index].cards = external[index].cards;
    } else {
        console.log('qrwa2')
        $scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
        $scope.lists[index].cards = external[index].cards;
    }
Run Code Online (Sandbox Code Playgroud)

如果我在同一个列表中进行移动并且我将卡移到更高的位置就可以了,那么必须执行:

$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard +1, 1);
Run Code Online (Sandbox Code Playgroud)

从上到下必须执行:

$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
Run Code Online (Sandbox Code Playgroud)

这里有问题我无法获得$ index在哪个地方我放卡如果我移动卡降低使这个表演,如果更高使这个表演...

这是整个项目:https: //plnkr.co/edit/BVF0KxPrWiCeGDXVpQDV?p = preview

sci*_*per 1

这段代码的工作原理:

$scope.dropCallback = function (index, item, external) {
  $scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
  $scope.lists[index].cards = external[index].cards;

  console.log($scope.lists[index].cards)

  return item;
};
Run Code Online (Sandbox Code Playgroud)

在这种情况下,观察者不是必需的,因为您是通过dropCallback函数本身来了解更改的。

您的工作只是删除索引处的项目,就像您所做的那样。与移动方向无关。

编辑

这是正在工作的笨蛋