简体   繁体   English

Angular 嵌套拖放到另一个列表

[英]Angular nested Drag And Drop into another list

I have a scenario, where I need to drop a feature into the respective item.我有一个场景,我需要将一个功能放入相应的项目中。 So, here I am using angular-material for drag and drop but it is dropping feature outside of the item, I want to insert the feature inside the item.所以,在这里我使用 angular-material 进行拖放,但它是在项目外部放置功能,我想在项目内插入功能。

Here is the sample: https://stackblitz.com/edit/angular-6cshhz-vsskhg?file=src%2Fapp%2Fcdk-drag-drop-connected-sorting-example.html[enter link description here] 1这是示例: https://stackblitz.com/edit/angular-6cshhz-vsskhg?file=src%2Fapp%2Fcdk-drag-drop-connected-sorting-example.html[在此处输入链接描述] 1

What is the configuration I need to do?我需要做什么配置? Anyone can help me?任何人都可以帮助我吗? Thanks!谢谢!

To be able to drag and drop first add this directive cdkDropListGroup to parent element.为了能够拖放,首先将此指令cdkDropListGroup添加到父元素。

After that change your array done to also include dropped items:之后更改您done数组以包括丢弃的项目:

  done = [
    {
      name: "Apple",
      items: [] <-- here will be stored the dropped item
    },

after that move the droplist to be child of each done item.之后将下拉列表移动为每个已done项目的子项。

  <div cdkDropList [cdkDropListData]="item.items" class="example-list" (cdkDropListDropped)="drop($event)">
    <div class="example-box" *ngFor="let it of item.items" cdkDrag>{{it}}</div>
  </div>

Working Stackblitz .工作Stackblitz Don't forget to "open" the accordion to see the "droplist".不要忘记“打开”手风琴以查看“下拉列表”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM