【发布时间】:2019-05-29 07:55:09
【问题描述】:
我有 2 个列表(左边是首都,右边是国家)。我希望能够在国家列表上移动首都,并允许用户将首都放在国家上。问题是国家列表元素开始移动/移动(以允许插入大写字母)。但我只想放在首位,如果匹配,请提供消息并从两个列表中删除城市+国家。
当我将城市元素拖到国家/地区列表元素上时,如何禁用目标国家/地区列表中的排序或元素移动?谢谢!
<div cdkDropList
[cdkDropListData]="capitals"
#capitalsList="cdkDropList"
[cdkDropListConnectedTo]="countryList">
<div cdkDrag
(cdkDragReleased)="onDragReleased($event)"
cdkDragBoundary=".row"
class="bg-info text-center border p-2"
*ngFor="let capital of capitals">{{ capital }}
</div>
</div>
<div cdkDropList
cdkDropListDisabled
[cdkDropListData]="countries"
#countryList="cdkDropList"
[cdkDropListConnectedTo]="capitalsList"
(cdkDropListDropped)="onDropListDropped($event)">
<div cdkDrag
cdkDragDisabled
class="text-center border p-2"
*ngFor="let country of countries">{{ country }}
</div>
</div>
【问题讨论】:
标签: angular drag-and-drop angular-cdk