2015-06-21 28 views
1

如何將拖放到我的列表中?AngularJS |如何包含拖放列表?

文件:list.tpl.html

<div class="panel-body"> 
<table class="table table-striped"> 
    <thead> 
    <tr> 
    <th>Lp.</th> 
    <th>Nazwa</th> 
    <th>Estymacja</th> 
    <th>Data</th> 
    <th>Ico</th> 
    <th>Zaznacz jako wykonane</th> 
    </tr> 
    </thead> 
    <tr data-ng-repeat="todo in todos"> 
    <td>{{$index+1}}. </td> 
    <td><span class="done-{{todo.done}}">{{todo.title}}</span></td> 
    <td><span class="done-{{todo.done}}">({{todo.estimates}}h)</span></td> 
    <td><span class="done-{{todo.done}}">{{todo.date}}</span></td> 
    <td><span class="glyphicon glyphicon-{{todo.type.gico}} done-{{todo.done}}"></span></td> 
    <td><input type="checkbox" data-ng-model="todo.done" title="Mark Complete" /></td> 
    </tr> 
</table> 

文件:列表ctrl.js

app.controller('listCtrl', function ($scope) { 
$scope.deleteCompleted = function() { 
    $scope.$parent.todos = $scope.$parent.todos.filter(function (item) { 
     return !item.done; 
    }); 
    }; 
}); 

我學習AngularJS,所以感謝您的幫助!

+0

從我的理解,你需要使用某種插件,並不直接支持拖放。看起來像「angular-dragdrop.js」就是其中之一。 – VSO

回答

0

我通常不喜歡添加插件到我的代碼,但在這種情況下,你可以添加一個簡單的模塊拖放。我用 ui-sortable

,那麼你需要簡單地做

<ul ui-sortable ng-model="items"> 
    <li ng-repeat="item in items">{{ item }}</li> 
</ul> 

這是一個列表...表我想不應該是真的不同

還檢查了該解決方案: solution