2016-03-07 184 views
1

我有兩個包含項目的表格。我希望能夠在表格之間拖放項目,但不能在同一個表格內拖放項目。角度ng-sortable如何在一個可拖動區域內禁用拖放

如何做到這一點?

謝謝。

+0

我發現我們將sortableOptions應用於ng-sortable元素。我們可以使用回調接受:函數(sourceItemHandleScope,destSortableScope) 我收到sourceItemHandleScope中的一個完整對象,並在開始移動item時收到大量事件。我無法弄清楚如何理解我將項目從一個ng-sortable區域移動到另一個 – migAlex

回答

1

您sortOptions裏面寫這篇接受功能:

//restrict move within table. move only across table. 
    accept: function (sourceItemHandleScope, destSortableScope, destItemScope) { 

      console.log("sourceItemHandleScope: ", sourceItemHandleScope); 
      console.log("destSortableScope: ", destSortableScope); 
      console.log("destItemScope: ", destItemScope); 

      return sourceItemHandleScope.itemScope.sortableScope.$parent.$id != destSortableScope.$parent.$id; 


    }, 

我已經使用的console.log查看範圍,看看如何去實現它,你可以將它們刪除。

相關問題