I have a Angular2 component using ng2-dragula to drag/drop like this:
@Component({
selector: 'my-comp',
directives: [
Dragula
],
viewProviders: [
DragulaService
],
template: `
<div class="my-div">
<div *ngFor="#item of items" [dragula]='"card-bag"' [dragulaModel]='items'>
...
</div>
</div>
`
})
My issue: if I create multiple "my-comp" component, item inside "card-bag" can not drag/drop across these component although they have the same bag name. These item are only able to drag/drop inside it owned component.
Do we have any configs for drag/drop across components, or this is ng2-dragula limitation?
Thanks.
If you are not using [dragulaModel]
then drag and drop between nested components works well as long as you only set viewProviders: [ DragulaService ]
once in the top/root component.
Remember not to set viewProviders: [ DragulaService ]
in other components as it creates new instances for every component.
Edit: Recently I have implemented the given scenario using ng2-dnd
npm package.
Its better than ng2-dragula and offers easy object passing and other things.
It might Solve your issue.