bevacqua / angularjs-dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/angularjs-dragula
MIT License
509 stars 110 forks source link

Error: Bag named: "..." already exists in same angular scope... can't use dragulaService #123

Closed mg1075 closed 6 years ago

mg1075 commented 6 years ago

Can someone please explain possible reasons for why one would get the following error when trying to use dragulaService.options inside the link function of a custom directive that injects dragulaService and in the html template of the directive includes a bag named whatever-bag? Error: Bag named: "whatever-bag" already exists in same angular scope. Yet if I do not use the dragulaService, and instead listen with scope.$on, there is no error?

mg1075 commented 6 years ago

Added a controller to the custom directive, and put the dragulaService call inside the controller, removing it from the directive's link function. The error went away.