'draggable true not working in angular
I have a div:
<div draggable = "true" ng-show="showPullDown" class="topPull stretch" draggable >
</div>
But draggable =true is not working. I have tried setting it through controller as well but no help. Any alternatives or fix?
directive:
.directive('draggable', function ($ionicGesture) {
return function(scope, element) {
// this gives us the native JS object
var startX = 0, startY = 0, x = 0, y = 0;
element.draggable=true;
var el = element[0];
element.css({
position: 'relative',
cursor: 'pointer'
});
$ionicGesture.on('dragstart', function(e) {
e.dataTransfer.effectAllowed = 'move';
return false;
}, element);
$ionicGesture.on('dragend', function(e) {
return false;
}, element);
}
})
I get an error..
Uncaught TypeError: Cannot set property 'effectAllowed' of undefined
Also, console.log(e) gives the event but console.log(e.dataTransfer) gives undefined.
Solution 1:[1]
This worked for me in Angular 1.
<div ng-attr-draggable="{{condition || undefined}}">
found the hint from the answers posted in the following question.
What is the best way to conditionally apply attributes in AngularJS?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mehdi Raza |
