Angular 7 Drag and Drop - Dynamically Create Drop Zones










5















Is there a way to dynamically create drop zones? I'm having some troubles with ngFor and cdkDropList.



Here is my first list and draggable elements:



 <div class="subj-container" 
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
[cdkDropListConnectedTo]="[lessonList]"
(cdkDropListDropped)="drop($event)"
>
<div class="subject" *ngFor="let subject of subjects" cdkDrag>
subject.name
</div>
</div>


And here is my second list:



 <div class="conta" cdkDropList
#lessonList="cdkDropList"
[cdkDropListData]="appointment.lessons"
[cdkDropListConnectedTo]="[subjectList]"
(cdkDropListDropped)="drop($event)">
<div class="sub" cdkDrag *ngFor="let lesson of appointment.lessons">
lesson.name
</div>
</div>


Now, div with class 'conta' is inside of a *ngFor.



My problem is, I suppose, with my second list. If I drag an element from second list to list one, it works normally, but if I try to drag element from list one to any instance of list in second list, it can't recognize that the element is being dragged. Demo here:



problem demo



Am I doing something wrong here?
The typescript part is working fine.



Thanks










share|improve this question
























  • Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

    – Lightheaded
    Nov 11 '18 at 16:02











  • @Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

    – sebamed
    Nov 11 '18 at 16:08
















5















Is there a way to dynamically create drop zones? I'm having some troubles with ngFor and cdkDropList.



Here is my first list and draggable elements:



 <div class="subj-container" 
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
[cdkDropListConnectedTo]="[lessonList]"
(cdkDropListDropped)="drop($event)"
>
<div class="subject" *ngFor="let subject of subjects" cdkDrag>
subject.name
</div>
</div>


And here is my second list:



 <div class="conta" cdkDropList
#lessonList="cdkDropList"
[cdkDropListData]="appointment.lessons"
[cdkDropListConnectedTo]="[subjectList]"
(cdkDropListDropped)="drop($event)">
<div class="sub" cdkDrag *ngFor="let lesson of appointment.lessons">
lesson.name
</div>
</div>


Now, div with class 'conta' is inside of a *ngFor.



My problem is, I suppose, with my second list. If I drag an element from second list to list one, it works normally, but if I try to drag element from list one to any instance of list in second list, it can't recognize that the element is being dragged. Demo here:



problem demo



Am I doing something wrong here?
The typescript part is working fine.



Thanks










share|improve this question
























  • Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

    – Lightheaded
    Nov 11 '18 at 16:02











  • @Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

    – sebamed
    Nov 11 '18 at 16:08














5












5








5


1






Is there a way to dynamically create drop zones? I'm having some troubles with ngFor and cdkDropList.



Here is my first list and draggable elements:



 <div class="subj-container" 
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
[cdkDropListConnectedTo]="[lessonList]"
(cdkDropListDropped)="drop($event)"
>
<div class="subject" *ngFor="let subject of subjects" cdkDrag>
subject.name
</div>
</div>


And here is my second list:



 <div class="conta" cdkDropList
#lessonList="cdkDropList"
[cdkDropListData]="appointment.lessons"
[cdkDropListConnectedTo]="[subjectList]"
(cdkDropListDropped)="drop($event)">
<div class="sub" cdkDrag *ngFor="let lesson of appointment.lessons">
lesson.name
</div>
</div>


Now, div with class 'conta' is inside of a *ngFor.



My problem is, I suppose, with my second list. If I drag an element from second list to list one, it works normally, but if I try to drag element from list one to any instance of list in second list, it can't recognize that the element is being dragged. Demo here:



problem demo



Am I doing something wrong here?
The typescript part is working fine.



Thanks










share|improve this question
















Is there a way to dynamically create drop zones? I'm having some troubles with ngFor and cdkDropList.



Here is my first list and draggable elements:



 <div class="subj-container" 
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
[cdkDropListConnectedTo]="[lessonList]"
(cdkDropListDropped)="drop($event)"
>
<div class="subject" *ngFor="let subject of subjects" cdkDrag>
subject.name
</div>
</div>


And here is my second list:



 <div class="conta" cdkDropList
#lessonList="cdkDropList"
[cdkDropListData]="appointment.lessons"
[cdkDropListConnectedTo]="[subjectList]"
(cdkDropListDropped)="drop($event)">
<div class="sub" cdkDrag *ngFor="let lesson of appointment.lessons">
lesson.name
</div>
</div>


Now, div with class 'conta' is inside of a *ngFor.



My problem is, I suppose, with my second list. If I drag an element from second list to list one, it works normally, but if I try to drag element from list one to any instance of list in second list, it can't recognize that the element is being dragged. Demo here:



problem demo



Am I doing something wrong here?
The typescript part is working fine.



Thanks







angular drag-and-drop angular7 angular-cdk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 8:42









Goncalo Peres

1,4541519




1,4541519










asked Nov 10 '18 at 12:45









sebamedsebamed

117111




117111












  • Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

    – Lightheaded
    Nov 11 '18 at 16:02











  • @Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

    – sebamed
    Nov 11 '18 at 16:08


















  • Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

    – Lightheaded
    Nov 11 '18 at 16:02











  • @Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

    – sebamed
    Nov 11 '18 at 16:08

















Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

– Lightheaded
Nov 11 '18 at 16:02





Does your second list work if you remove the styling that makes it multiline? The droplists can only be either horizontal or vertical. What you seem to have here is a grid, which won't work because there is inherent logic that relies on knowing whether to calculate the relative distances of droplist elements in x or y dimension.

– Lightheaded
Nov 11 '18 at 16:02













@Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

– sebamed
Nov 11 '18 at 16:08






@Lightheaded - Yes, I actually thought of that, and removed all styles, but no. I found a solution. There was a problem with cdkDropListConnectedTo. It was connected to null, so I made my workaround. Check my answer bellow, and thanks!

– sebamed
Nov 11 '18 at 16:08













2 Answers
2






active

oldest

votes


















5














After a full day of research, I found this pull request on Angular CDK repository on Github. Now, since I did not know how to integrate cdkDropListGroup into my example, I decited to create an array of IDs which will be added to [cdkDropListConnectedTo].



Each instance of my second list will have generated ID, and that ID will be added to array with suitable prefix (in my second list, on cdkDropList):



<div cdkDropList
[attr.id]="addId(i, j)"
[cdkDropListData]="appointment.lessons"
[cdkDropListConnectedTo]="[subjectList]"
(cdkDropListDropped)="drop($event)"
>


addId method:



addId(i, j) 
this.LIST_IDS.push('cdk-drop-list-' + i + '' + j);
return i + '' + j;



(cdk-drop-list- is an ID prefix. CDK places this prefix on every element with cdkDropList attribute)



So, my array will look like:



  • cdk-drop-list-00

  • cdk-drop-list-01

  • cdk-drop-list-02

  • etc.

Now, I pass that array to [cdkDropListConnectedTo] in my first list:



<div class="subj-container" 
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
[cdkDropListConnectedTo]="LIST_IDS"
(cdkDropListDropped)="drop($event)"
>


And it works flawlessly!



Hope this will help anybody with the same problem. Also, take a look at the pull request I mentioned, my solution is only a workaround, there is probably a better solution with cdkDropListGroup






share|improve this answer


















  • 1





    cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

    – Lightheaded
    Nov 12 '18 at 5:52












  • cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

    – Jomy Joseph
    Nov 23 '18 at 15:58











  • I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

    – Maxxx
    Nov 27 '18 at 4:01



















2














With cdkDropListGroup you can now do:






<div cdkDropListGroup>

<div cdkDropList
[cdkDropListData]="data"
(cdkDropListDropped)="drop($event)">
<div class="row m-2">
<div *ngFor="let i of data cdkDrag>i</div>
</div>
</div>

<div class="subj-container"
cdkDropListOrientation="horizontal"
cdkDropList
#subjectList="cdkDropList"
[cdkDropListData]="subjects"
(cdkDropListDropped)="drop($event)">
</div>

</div>





No longer a need for cdkDropListConnectedTo in this case.
See https://github.com/angular/material2/blob/master/src/cdk/drag-drop/drag-drop.md






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239092%2fangular-7-drag-and-drop-dynamically-create-drop-zones%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    After a full day of research, I found this pull request on Angular CDK repository on Github. Now, since I did not know how to integrate cdkDropListGroup into my example, I decited to create an array of IDs which will be added to [cdkDropListConnectedTo].



    Each instance of my second list will have generated ID, and that ID will be added to array with suitable prefix (in my second list, on cdkDropList):



    <div cdkDropList
    [attr.id]="addId(i, j)"
    [cdkDropListData]="appointment.lessons"
    [cdkDropListConnectedTo]="[subjectList]"
    (cdkDropListDropped)="drop($event)"
    >


    addId method:



    addId(i, j) 
    this.LIST_IDS.push('cdk-drop-list-' + i + '' + j);
    return i + '' + j;



    (cdk-drop-list- is an ID prefix. CDK places this prefix on every element with cdkDropList attribute)



    So, my array will look like:



    • cdk-drop-list-00

    • cdk-drop-list-01

    • cdk-drop-list-02

    • etc.

    Now, I pass that array to [cdkDropListConnectedTo] in my first list:



    <div class="subj-container" 
    cdkDropListOrientation="horizontal"
    cdkDropList
    #subjectList="cdkDropList"
    [cdkDropListData]="subjects"
    [cdkDropListConnectedTo]="LIST_IDS"
    (cdkDropListDropped)="drop($event)"
    >


    And it works flawlessly!



    Hope this will help anybody with the same problem. Also, take a look at the pull request I mentioned, my solution is only a workaround, there is probably a better solution with cdkDropListGroup






    share|improve this answer


















    • 1





      cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

      – Lightheaded
      Nov 12 '18 at 5:52












    • cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

      – Jomy Joseph
      Nov 23 '18 at 15:58











    • I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

      – Maxxx
      Nov 27 '18 at 4:01
















    5














    After a full day of research, I found this pull request on Angular CDK repository on Github. Now, since I did not know how to integrate cdkDropListGroup into my example, I decited to create an array of IDs which will be added to [cdkDropListConnectedTo].



    Each instance of my second list will have generated ID, and that ID will be added to array with suitable prefix (in my second list, on cdkDropList):



    <div cdkDropList
    [attr.id]="addId(i, j)"
    [cdkDropListData]="appointment.lessons"
    [cdkDropListConnectedTo]="[subjectList]"
    (cdkDropListDropped)="drop($event)"
    >


    addId method:



    addId(i, j) 
    this.LIST_IDS.push('cdk-drop-list-' + i + '' + j);
    return i + '' + j;



    (cdk-drop-list- is an ID prefix. CDK places this prefix on every element with cdkDropList attribute)



    So, my array will look like:



    • cdk-drop-list-00

    • cdk-drop-list-01

    • cdk-drop-list-02

    • etc.

    Now, I pass that array to [cdkDropListConnectedTo] in my first list:



    <div class="subj-container" 
    cdkDropListOrientation="horizontal"
    cdkDropList
    #subjectList="cdkDropList"
    [cdkDropListData]="subjects"
    [cdkDropListConnectedTo]="LIST_IDS"
    (cdkDropListDropped)="drop($event)"
    >


    And it works flawlessly!



    Hope this will help anybody with the same problem. Also, take a look at the pull request I mentioned, my solution is only a workaround, there is probably a better solution with cdkDropListGroup






    share|improve this answer


















    • 1





      cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

      – Lightheaded
      Nov 12 '18 at 5:52












    • cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

      – Jomy Joseph
      Nov 23 '18 at 15:58











    • I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

      – Maxxx
      Nov 27 '18 at 4:01














    5












    5








    5







    After a full day of research, I found this pull request on Angular CDK repository on Github. Now, since I did not know how to integrate cdkDropListGroup into my example, I decited to create an array of IDs which will be added to [cdkDropListConnectedTo].



    Each instance of my second list will have generated ID, and that ID will be added to array with suitable prefix (in my second list, on cdkDropList):



    <div cdkDropList
    [attr.id]="addId(i, j)"
    [cdkDropListData]="appointment.lessons"
    [cdkDropListConnectedTo]="[subjectList]"
    (cdkDropListDropped)="drop($event)"
    >


    addId method:



    addId(i, j) 
    this.LIST_IDS.push('cdk-drop-list-' + i + '' + j);
    return i + '' + j;



    (cdk-drop-list- is an ID prefix. CDK places this prefix on every element with cdkDropList attribute)



    So, my array will look like:



    • cdk-drop-list-00

    • cdk-drop-list-01

    • cdk-drop-list-02

    • etc.

    Now, I pass that array to [cdkDropListConnectedTo] in my first list:



    <div class="subj-container" 
    cdkDropListOrientation="horizontal"
    cdkDropList
    #subjectList="cdkDropList"
    [cdkDropListData]="subjects"
    [cdkDropListConnectedTo]="LIST_IDS"
    (cdkDropListDropped)="drop($event)"
    >


    And it works flawlessly!



    Hope this will help anybody with the same problem. Also, take a look at the pull request I mentioned, my solution is only a workaround, there is probably a better solution with cdkDropListGroup






    share|improve this answer













    After a full day of research, I found this pull request on Angular CDK repository on Github. Now, since I did not know how to integrate cdkDropListGroup into my example, I decited to create an array of IDs which will be added to [cdkDropListConnectedTo].



    Each instance of my second list will have generated ID, and that ID will be added to array with suitable prefix (in my second list, on cdkDropList):



    <div cdkDropList
    [attr.id]="addId(i, j)"
    [cdkDropListData]="appointment.lessons"
    [cdkDropListConnectedTo]="[subjectList]"
    (cdkDropListDropped)="drop($event)"
    >


    addId method:



    addId(i, j) 
    this.LIST_IDS.push('cdk-drop-list-' + i + '' + j);
    return i + '' + j;



    (cdk-drop-list- is an ID prefix. CDK places this prefix on every element with cdkDropList attribute)



    So, my array will look like:



    • cdk-drop-list-00

    • cdk-drop-list-01

    • cdk-drop-list-02

    • etc.

    Now, I pass that array to [cdkDropListConnectedTo] in my first list:



    <div class="subj-container" 
    cdkDropListOrientation="horizontal"
    cdkDropList
    #subjectList="cdkDropList"
    [cdkDropListData]="subjects"
    [cdkDropListConnectedTo]="LIST_IDS"
    (cdkDropListDropped)="drop($event)"
    >


    And it works flawlessly!



    Hope this will help anybody with the same problem. Also, take a look at the pull request I mentioned, my solution is only a workaround, there is probably a better solution with cdkDropListGroup







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 11 '18 at 16:07









    sebamedsebamed

    117111




    117111







    • 1





      cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

      – Lightheaded
      Nov 12 '18 at 5:52












    • cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

      – Jomy Joseph
      Nov 23 '18 at 15:58











    • I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

      – Maxxx
      Nov 27 '18 at 4:01













    • 1





      cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

      – Lightheaded
      Nov 12 '18 at 5:52












    • cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

      – Jomy Joseph
      Nov 23 '18 at 15:58











    • I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

      – Maxxx
      Nov 27 '18 at 4:01








    1




    1





    cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

    – Lightheaded
    Nov 12 '18 at 5:52






    cdkDropListGroup is not a released feature yet. Look out for next releases. Meanwhile, I've been using the same approach – use a mapping by list IDs. There seems no better way to do it at the moment. Whenever your mentioned feature gets released, you can remove all that hacky messing with IDs :)

    – Lightheaded
    Nov 12 '18 at 5:52














    cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

    – Jomy Joseph
    Nov 23 '18 at 15:58





    cdkDropListGroup is released. Can I get this demo with cdkDropListGroup anywhere?

    – Jomy Joseph
    Nov 23 '18 at 15:58













    I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

    – Maxxx
    Nov 27 '18 at 4:01






    I added a demo with cdkDropListGroup on StackBlitz at stackblitz.com/edit/angular-a4ftm7

    – Maxxx
    Nov 27 '18 at 4:01














    2














    With cdkDropListGroup you can now do:






    <div cdkDropListGroup>

    <div cdkDropList
    [cdkDropListData]="data"
    (cdkDropListDropped)="drop($event)">
    <div class="row m-2">
    <div *ngFor="let i of data cdkDrag>i</div>
    </div>
    </div>

    <div class="subj-container"
    cdkDropListOrientation="horizontal"
    cdkDropList
    #subjectList="cdkDropList"
    [cdkDropListData]="subjects"
    (cdkDropListDropped)="drop($event)">
    </div>

    </div>





    No longer a need for cdkDropListConnectedTo in this case.
    See https://github.com/angular/material2/blob/master/src/cdk/drag-drop/drag-drop.md






    share|improve this answer



























      2














      With cdkDropListGroup you can now do:






      <div cdkDropListGroup>

      <div cdkDropList
      [cdkDropListData]="data"
      (cdkDropListDropped)="drop($event)">
      <div class="row m-2">
      <div *ngFor="let i of data cdkDrag>i</div>
      </div>
      </div>

      <div class="subj-container"
      cdkDropListOrientation="horizontal"
      cdkDropList
      #subjectList="cdkDropList"
      [cdkDropListData]="subjects"
      (cdkDropListDropped)="drop($event)">
      </div>

      </div>





      No longer a need for cdkDropListConnectedTo in this case.
      See https://github.com/angular/material2/blob/master/src/cdk/drag-drop/drag-drop.md






      share|improve this answer

























        2












        2








        2







        With cdkDropListGroup you can now do:






        <div cdkDropListGroup>

        <div cdkDropList
        [cdkDropListData]="data"
        (cdkDropListDropped)="drop($event)">
        <div class="row m-2">
        <div *ngFor="let i of data cdkDrag>i</div>
        </div>
        </div>

        <div class="subj-container"
        cdkDropListOrientation="horizontal"
        cdkDropList
        #subjectList="cdkDropList"
        [cdkDropListData]="subjects"
        (cdkDropListDropped)="drop($event)">
        </div>

        </div>





        No longer a need for cdkDropListConnectedTo in this case.
        See https://github.com/angular/material2/blob/master/src/cdk/drag-drop/drag-drop.md






        share|improve this answer













        With cdkDropListGroup you can now do:






        <div cdkDropListGroup>

        <div cdkDropList
        [cdkDropListData]="data"
        (cdkDropListDropped)="drop($event)">
        <div class="row m-2">
        <div *ngFor="let i of data cdkDrag>i</div>
        </div>
        </div>

        <div class="subj-container"
        cdkDropListOrientation="horizontal"
        cdkDropList
        #subjectList="cdkDropList"
        [cdkDropListData]="subjects"
        (cdkDropListDropped)="drop($event)">
        </div>

        </div>





        No longer a need for cdkDropListConnectedTo in this case.
        See https://github.com/angular/material2/blob/master/src/cdk/drag-drop/drag-drop.md






        <div cdkDropListGroup>

        <div cdkDropList
        [cdkDropListData]="data"
        (cdkDropListDropped)="drop($event)">
        <div class="row m-2">
        <div *ngFor="let i of data cdkDrag>i</div>
        </div>
        </div>

        <div class="subj-container"
        cdkDropListOrientation="horizontal"
        cdkDropList
        #subjectList="cdkDropList"
        [cdkDropListData]="subjects"
        (cdkDropListDropped)="drop($event)">
        </div>

        </div>





        <div cdkDropListGroup>

        <div cdkDropList
        [cdkDropListData]="data"
        (cdkDropListDropped)="drop($event)">
        <div class="row m-2">
        <div *ngFor="let i of data cdkDrag>i</div>
        </div>
        </div>

        <div class="subj-container"
        cdkDropListOrientation="horizontal"
        cdkDropList
        #subjectList="cdkDropList"
        [cdkDropListData]="subjects"
        (cdkDropListDropped)="drop($event)">
        </div>

        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 16:40









        avocadocommanderavocadocommander

        211




        211



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239092%2fangular-7-drag-and-drop-dynamically-create-drop-zones%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Crossroads (UK TV series)

            ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế