2
我正在使用ng-sortable來重新排列列表元素的功能。 在這我打算申請NG-對列表進行排序是:TypeError:無法讀取未定義的屬性'0' - ng-Sortable(AngularJs)
List B : [object Object],[object Object],[object Object]
以下是我的代碼:
HTML -
<div data-as-sortable-item-handle>
<!-- <div class="list-group-item"> -->
{{$index + 1}}{{user.Name}} <input ng-click="ctrl.selectB(user.id)" name="ctrl.selectedB[]" value="{{user.id}}" ng-checked="ctrl.selectedB.indexOf(user.id) > -1"
type="checkbox" class="pull-right">
<!-- </div> -->
</div>
</li>
</ul>
控制器 -
$scope.dragControlListeners = {
accept: function (sourceItemHandleScope, destSortableScope)
{return sourceItemHandleScope.itemScope.sortableScope.$id === destSortableScope.$id;},
itemMoved: function (event) {
//Do what you want },
},
orderChanged: function(event) {
//Do what you want},
}
};
但我得到的錯誤:
TypeError: Cannot read property '0' of undefined
TypeError: Cannot read property '1' of undefined
,當我嘗試拖動的元素,所有元素都被視爲一個單獨的單元,並拖累,在行動上,我想每個L1元素indivually行動並可拖動。
收到錯誤 -
Uncaught TypeError: Cannot read property 'splice' of undefined
好吧!將嘗試 – Learner
但我發現執行此拖放操作的另一個更好和更好的庫是angular-dndlists(https://github.com/marceljuenemann/angular-drag-and-drop-lists)。 試試吧! – Learner