zack9433
zack9433

Reputation: 23

How to implement drag and drop using angular-dragdrop

i have a question about using angular-dragdrop.

Here is the code: http://plnkr.co/edit/sNZ3xQK1fYMlBf8rX5Kb?p=preview

I want to drag first section item into second section. These section are different controller and how to fix that?

Upvotes: 2

Views: 2021

Answers (2)

codef0rmer
codef0rmer

Reputation: 10520

Agreed, I'm late to the party but one of the contributors had provided a patch to the same problem you are facing because I did not consider such scenario (multi controller drag & drop) while writing it.

I've updated the angular-dragdrop.js file in your demo to make it work. Hope you like it!

http://plnkr.co/edit/lWwHD0TGIiEw6p7imQtz?p=preview

Upvotes: 1

Ketan
Ketan

Reputation: 5891

Please go through the AngularJS Directives documentation. All UI code has to be inside directives.

It is ok for both sections to have their own controllers. Basically you need to add directives to both section templates. On the directive that is the target section, you handle the appropriate JQuery callback and either use scope.broadcast/scope.on or use services to communicate between the controllers.

Upvotes: 0

Related Questions