Created
April 23, 2015 03:49
-
-
Save gangadharjannu/f0185766831f5eadcb04 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/fotadurova
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="myApp"> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
#div1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;} | |
</style> | |
</head> | |
<body ng-controller="myController"> | |
<h1>Drag the W3Schools image into the rectangle:</h1> | |
<div id="div1" bin></div> | |
<ul> | |
<li item id="item1">item1</li> | |
<li item id="item2">item2</li> | |
<li id="item3">item3</li> | |
</ul> | |
<script id="jsbin-javascript"> | |
var app=angular.module("myApp", []); | |
app.controller("myController", function($scope){ | |
$scope.hi='hi'; | |
}); | |
app.directive("bin", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.on('dragover', function(event){ | |
event.preventDefault(); | |
}); | |
ele.on('drop', function(event){ | |
event.preventDefault(); | |
var data=event.dataTransfer.getData("text"); | |
console.log(data); | |
var element=document.getElementById(data); | |
element.parentNode.removeChild(element); | |
}); | |
} | |
}; | |
}); | |
app.directive("item", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.attr("draggable", 'true'); | |
ele.on('dragstart', function(event){ | |
console.log(event); | |
event.dataTransfer.setData("text", event.target.id); | |
}); | |
} | |
}; | |
}); | |
</script> | |
<script id="jsbin-source-css" type="text/css">#div1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var app=angular.module("myApp", []); | |
app.controller("myController", function($scope){ | |
$scope.hi='hi'; | |
}); | |
app.directive("bin", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.on('dragover', function(event){ | |
event.preventDefault(); | |
}); | |
ele.on('drop', function(event){ | |
event.preventDefault(); | |
var data=event.dataTransfer.getData("text"); | |
console.log(data); | |
var element=document.getElementById(data); | |
element.parentNode.removeChild(element); | |
}); | |
} | |
}; | |
}); | |
app.directive("item", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.attr("draggable", 'true'); | |
ele.on('dragstart', function(event){ | |
console.log(event); | |
event.dataTransfer.setData("text", event.target.id); | |
}); | |
} | |
}; | |
}); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#div1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app=angular.module("myApp", []); | |
app.controller("myController", function($scope){ | |
$scope.hi='hi'; | |
}); | |
app.directive("bin", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.on('dragover', function(event){ | |
event.preventDefault(); | |
}); | |
ele.on('drop', function(event){ | |
event.preventDefault(); | |
var data=event.dataTransfer.getData("text"); | |
console.log(data); | |
var element=document.getElementById(data); | |
element.parentNode.removeChild(element); | |
}); | |
} | |
}; | |
}); | |
app.directive("item", function(){ | |
return { | |
//restrict:"A", | |
link:function(scope,ele,attrs){ | |
ele.attr("draggable", 'true'); | |
ele.on('dragstart', function(event){ | |
console.log(event); | |
event.dataTransfer.setData("text", event.target.id); | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment