I want to know how to do drag and drop by using AngularJs.
This is what I have so far:
<span><input type="checkbox" ng-model="master"><span>SelectAll</span></span>
<div ng-repeat="todo in todos">
<div ng-hide="enableEditor">
<a href="#">Drag</a>
<input id="checkSlave" type="checkbox" ng-checked="master" ng-model="todo.done">
<span ng-if="checked" ng-show="removed" ng-bind="todo.task_name" class="removed"></span>
<span ng-bind="todo.task_name"></span>
<span ng-bind="todo.state"></span>
<a href="#" ng-click="editTask(todo.task_id,todo.task_name,editMode=!editMode)">Edit</a>
</div>
</div>
<div ng-show="enableEditor">
<input type="text" ng-show="editMode" ng-model="todo.task_name" ng-change="update(todo.task_id,todo.task_name)">
<a href="#" ng-click="saveTask(todo.task_id,todo.task_name,editMode=!editMode)">Save</a>
<a href="#" ng-click="cancelTask(todo.task_id,todo.task_name,editMode=!editMode)">Cancel</a>
</div>
</div>
Using HTML 5 Drag and Drop
You can easily archive this using HTML 5 drag and drop feature along with angular directives.
Find the example below in which
list
is array of items.HTML code:
Javascript:
Find the complete code here https://github.com/raghavendrarai/SimpleDragAndDrop
small scripts for drag and drop by angular
source link
I'm a bit late to the party, but I have my own directive that looks like it'll fit your case (You can adapt it yourself). It's a modification of the ng-repeat directive that's specifically built for list re-ordering via DnD. I built it as I don't like JQuery UI (preference for less libraries than anything else) also I wanted mine to work on touch screens too ;).
Code is here: http://codepen.io/SimeonC/pen/AJIyC
Blog post is here: http://sdevgame.wordpress.com/2013/08/27/angularjs-drag-n-drop-re-order-in-ngrepeat/
I just posted this to my brand spanking new blog: http://jasonturim.wordpress.com/2013/09/01/angularjs-drag-and-drop/
Code here: https://github.com/logicbomb/lvlDragDrop
Demo here: http://logicbomb.github.io/ng-directives/drag-drop.html
Here are the directives these rely on a UUID service which I've included below:
UUID service
Modified from the angular-drag-and-drop-lists examples page
Markup
Angular
Library can be installed via bower or npm: angular-drag-and-drop-lists
Angular doesn't provide snazzy UI elements like drag and drop. That's not really Angular's purpose. However, there are a few well known directives that provide drag and drop. Here are two that I've used.
https://github.com/angular-ui/ui-sortable
https://github.com/codef0rmer/angular-dragdrop