很明显,事件对象非常庞大且难以导航。我试图使用ondrop事件获取我的目标元素的data-id属性。所以
onItemDrop(event: any) {
// Get the dropped data here
console.log(event.///GET THE data-id attribute of the target element);
}
html:
<div id="{{ column.id }}"
class="board-body"
data-id="{{ column.id }}"
(onDrop)="onItemDrop($event)"
droppable>
<div class="card bg-light-blue mb-2" *ngFor="let item of (results | groupBy: column.id)" [dragData]="item" draggable>
<div class="card-body">
<div class="card-title mb-0">
<h6>
<span class="text-primary"><strong>{{ item.contactName }}</strong></span>
<span class="text-secondary">- {{ item.mediaOutletName }}</span>
</h6>
<button class="btn btn-transparent p-0">
<small><i class="fa fa-caret-down p-0"></i></small>
</button>
</div>
<div class="card-text text-dark">
Sent: {{ item.updatedDate | date }}
</div>
</div>
</div>
</div>
我需要这个,因为如果项目删除了id,那么我将添加到脚本中来更改数据,以便它匹配它被放入的元素的id?