我使用angular 6和angular-cdk 8.0.0进行proyect拖放,我需要移动元素以知道顺序在哪里,更新和aslo删除它们,但是我不知道该怎么做
我试图在角度cdk中使用api,但是我更加困惑了,我试图从数组中删除该项目,但是拖放操作已损坏
<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let name of names" cdkDrag>
{{name}}
</div>
</div>
names: string[];
order: number[];
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.order, event.previousIndex, event.currentIndex);
moveItemInArray(this.names, event.previousIndex, event.currentIndex);
}
onYesClick(): void {
for(let i = 0; i < this.names.length; i++){
this.dashboard.updateChartOrder(this.charts[i],this.order[i]).subscribe();
}
this.dialogRef.close({});
}
错误是因为从阵列中删除该项目时,该项目永不消失