Skip to content Skip to sidebar Skip to footer

CdkDropList With Ng-template On Dynamic Component List Do'snt Work

I'm trying to use Drag&Drop features released with Angular Material 7. And dynamically creating component using ng-tempalte.

CdkDrag uses dependency injection to find out whether it's inside a CdkDropList which doesn't work when the template is inside a different component. For more advanced cases like this one you can use the DragDrop service to attach the drag&drop functionality yourself.

Refer https://github.com/angular/material2/issues/15553

Stackblitz code for implementation of cdkService: https://stackblitz.com/edit/angular-ngtemplate-reorder-7i6uuk?file=src%2Fapp%2Fapp.component.ts

hope this helps out someone else.


Post a Comment for "CdkDropList With Ng-template On Dynamic Component List Do'snt Work"