So, I have this following template.
<div dragula="'card-images'" [dragulaModel]="images">
<child-component [card]="imageCard" [ngClass]="cssClass(card)" *ngFor="let imageCard of images"></child-component>
</div>
The function cssClass sets the class based on the type of imageCard. So it is set to draggable and non draggable based on the type of image Card. Now, I want the child component to be draggable only if its property isSelected is true only after long press and this is done dynamically. How can I achieve this ? How to make child component draggable at run time ?
Thank you.
You can provide moves
function and put the condition when the items should be dragable.
In your case, you can do it two steps -
<child-component [ngClass]="{'no-drag' : card.selected != true}"></child-component>
no-drag
. constructor(private dragulaService: DragulaService) {
dragulaService.setOptions('card-images', {
moves: (el, source, handle, sibling) => !el.classList.contains('no-drag')
});
}