Search code examples
angulartypescriptng2-dragula

Dragula drag and drop one way with copy ng2


I am trying to drag and drop one way with copy with ng2 dragula This is my template.

`<div>
   <div class='wrapper'>
     <div class='container' id='no-drop' [dragula]='"first-bag"'>
       <div>Drag/drop item 1</div>
     </div>
     <div class='container' [dragula]='"first-bag"'>
       <div>Drag/drop item 2</div>
     </div>
   </div>
 </div>` 

I have set the option to copy in my component.

constructor(private dragulaService: DragulaService) {
dragulaService.setOptions('first-bag', {
  copy: true
});

But if i set moves to false, i am not able to drag at all. How can i move from left to right and not the other way.


Solution

  • I found the answer soon after posting!!

       constructor(private dragulaService: DragulaService) {
        dragulaService.setOptions('first-bag', {
          copy: true,
          moves: function (el, container, handle) {
            return container.id !== 'no-drop';
          }
        });