Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ondrop ondragover - Uncaught ReferenceError: ondrop is not defined - angular - html5 draggable

Tags:

html

angularjs

I try to implement html5 drag and drop with angular.

The code is:

<div ondrop="drop(event)"></div>

And in the controller:

$scope.drop = function(e) { console.log('a drop') };

This leads to the error:

Uncaught ReferenceError: drop is not defined

Exchanging 'ondrop' with 'ng-click' makes it work, so there is nothing missing in the controller.

like image 732
Stefan Avatar asked Nov 15 '25 12:11

Stefan


1 Answers

ondrop is a HTML attribute, therefore it expects the given function to be global, as opposed to angular directives such as ng-click which expect the callbacks to be published on the $scope.

like image 190
LoremIpsum Avatar answered Nov 17 '25 09:11

LoremIpsum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!