Home > Blockchain >  Angular drag and drop, exit event, get data of removed item
Angular drag and drop, exit event, get data of removed item

Time:04-12

I'm trying to get value or index of the item removed from the source list using the "cdkDropListExited" event. I do see the event getting fired but the "event.item.data" keeps coming as "undefined".

How can I get the value or index of a list item as soon as it is moved from a drop container into another one.

Demo/Example here

CodePudding user response:

Well, that is simply beause you're not assigning any data to you cdkDrag.

Take a look at the docs here and look for cdkDragData.

So, in your code it would like this:

<div  *ngFor="let item of todo" cdkDrag [cdkDragData]="item">{{item}}</div>
  • Related