问题
I am using native Angular 7 Drag&Drop provided by @angular/cdk/drag-drop
.
Basically, I just need to create one sortable list inside another one as in the code below:
<div class="external-list" cdkDropList (cdkDropListDropped)="drop1($event)">
<div class="external-item" cdkDrag *ngFor="let item of items">
{{item.header}}
<div class="internal-list" cdkDropList (cdkDropListDropped)="drop2($event)">
<div class="internal-item" cdkDrag *ngFor="let row of item.rows">
{{row}}
</div>
</div>
</div>
</div>
This is a very schematic example just to demonstrate the purpose.
The problem is when I try dragging the inner items outer ones are dragged instead.
How can I solve this without resorting to 3rd-party packages?
回答1:
I think you will need to use a drag handle (cdkDragHandle
on an element inside cdkDrag
), at least for the parent list.
https://material.angular.io/cdk/drag-drop/overview#customizing-the-drag-area-using-a-handle
来源:https://stackoverflow.com/questions/53120167/angular-7-dragdrop-nested-lists-with-native-cdk