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