Drag'n'drop dataTransfer.getData empty
The data is only available on drop, this is a security feature since a website could grab data when you happen to be dragging something across the webpage.
var el = angular.element(document.getElementById('drag'));
el.attr("draggable", "true");
el.bind("dragstart", function(e) {
e.dataTransfer.setData('text', 'Where have you gone?!?!')
});
var target = angular.element(document.getElementById('drop'));
target.bind("dragover", function(e) {
if (e.preventDefault) {
e.preventDefault(); // Necessary. Allows us to drop.
}
return false;
});
target.bind("drop", function(e) {
console.debug(e.dataTransfer.types);
console.debug(e.dataTransfer.getData('text'));
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div id="drag" style="width: 100px; height: 100px; background-color: blue;"></div>
<div id="drop" style="width: 100px; height: 100px; background-color: green;"></div>