【发布时间】:2019-03-18 16:11:47
【问题描述】:
我正在尝试使用 Angular Material 7 发布的拖放功能。并使用 ng-tempalte 动态创建组件。
<div cdkDropList (cdkDropListDropped)="dropLocal($event)">
<ng-template #components></ng-template>
</div>
并在组件处添加了 cdkDrag。
我在父组件中使用 createComponent 来继续创建组件。
viewContainerRef.createComponent
但拖放功能无法使用,因为cdkDrag must be in a tag nested inside the one with cdkDropList, otherwise the dragged element won't detect the drop zone.
参考:https://stackoverflow.com/a/54158293/4481952
有没有办法让 dropfunctionality 工作?
演示代码https://stackblitz.com/edit/angular-ngtemplate-reorder?file=src%2Fapp%2Fapp.component.html
【问题讨论】:
标签: javascript angular drag-and-drop angular-material angular7