I cannot figure out how to use Angular's Drag and Drop module for something other than move items between lists.
I have a list of items and I want to drag them on individual groups. Incidentally, there are two lists involved here, one list with groups and one list with items.
Here's the template code (please see this https://stackblitz.com/edit/angular-xp4um9 for the full code):
<div class="container">
<div class="drop-target">
<mat-selection-list
cdkDropList
#dropTarget="cdkDropList"
(cdkDropListDropped)="drop($event)"
[cdkDropListData]="groups"
>
<mat-list-option *ngFor="let group of groups" [value]="group.id"
>
{{ group.name }}
</mat-list-option>
</mat-selection-list>
</div>
<div class="drag-source">
<mat-selection-list
cdkDropList
[cdkDropListConnectedTo]="[dropTarget]"
>
<mat-list-option *ngFor="let item of items" [value]="item.id"
cdkDrag
[cdkDragData]="item"
>
{{ item.name }}
</mat-list-option>
</mat-selection-list>
</div>
</div>
I want to drag an item from the second list and drop it onto a group in the first list, not as a new element of the second list, as documented everywhere on the internet, but to become part of the group it is dropped onto.
I'd like to be able to get in the drop() function the source item and the destination group.
Also, how can I prevent the first list from shrinking when dragging the item over the second list and also prevent the item appearing below the groups (as in the image below) ?
Thanks.
