TypeError:无法读取未定义的属性"0" - ng-Sortable(AngularJs)

Lea*_*ner 2 angularjs ng-sortable

我使用ng-sortable来重新排序列表元素的功能.我打算应用ng-sortable的列表是:

列表B:[对象对象],[对象对象],[对象对象]

以下是我的代码:

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>
Run Code Online (Sandbox Code Playgroud)

控制器 -

$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},
                        }
                                        };
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

TypeError:无法读取未定义的属性"0"

TypeError:无法读取未定义的属性"1"

当我尝试拖动元素时,所有元素都被视为一个单元并被拖动,在契约中我希望每个元素单独行动并且可以拖动.

得到错误 -

未捕获的TypeError:无法读取undefined的属性'splice'

小智 6

你有更多代码向我们展示吗?今天有相同的错误消息并通过将ng-model设置为与ng-repeat相同的列表来修复它.

<div as-sortable="dragControlListeners" ng-model="foo">
   <div ng-repeat="bar in foo">
     <div as-sortable-item class="as-sortable-item">
        Lorum ipsum
        <div as-sortable-item-handle class="as-sortable-item-handle">Drag</div>
     </div>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)