我有一个基本的ng-repeat,其中任务是可排序的
<div ng-sortable="sortableOptions">
<div ng-repeat="task in todo">
{{task}}
...当一个任务被拖放时,它会在我的控制器中调用$scope.sortableOptions。我想知道是否有人知道我是如何将任务对象传递给它的?我可以把它设置为函数或者..。
基本上,我希望传入任务并更新todo固有的属性之一。
$scope.sortableOptions2 = {
stop: function(event, ui) {
// do something with the specific todo here
});
}谢谢你
发布于 2015-03-17 11:52:31
如果你正在使用ng-sortable是的,你可以做到,
<ul data-as-sortable="sortableOptions" data-ng-model="todo">
<li data-ng-repeat="item in todo" data-as-sortable-item>
<div data-as-sortable-item-handle></div>
</li>
</ul>在你的控制器里,
$scope.sortableOptions = {
accept: function (sourceItemHandleScope, destSortableScope) {return boolean}//override to determine drag is allowed or not. default is true.
itemMoved: function (event) {//Do what you want},
orderChanged: function(event) {//Do what you want},
containment: '#board'//optional param.
};https://stackoverflow.com/questions/29090910
复制相似问题