For some reason (read: Cannot create many components), I have to create sections on my app which will be able to act as drop elements. (cannot use *ngIf
)
I created DropListRef like -
constructor(private dragDropService: DragDrop) {}
const dropListRef = this.dragDropService
.createDropList(dropZone)
.withItems([]);
And I am trying to detect whether an element has been dropped as -
dropListRef.dropped.subscribe(event => {
console.log("dropped: ");
});
However, I never find the console output.
Link to sample code - https://stackblitz.com/edit/angular-r3spyc
Link to demo video - https://drive.google.com/file/d/1b6RUuOk9r7s9vFd3NlhgR9ot1hHP1Oeb/view
Cannot create many components
- The way I have written in not atypical with the examples shown on the Angular official site, however, the same docs advertise an ability to createDropList() here given a native-element. If you inspect it further - the code creates a DropListRef and adds an element to the DOM, however, it does not respond to events such as
dropped
,entered
. It feels that I am missing some important steps like registering it somewhere or connecting with the other DropList which then Angular Material can recognize or identify it. - The reason I cannot create a single component (for example - a
Dropbox component
) because that would be oversimplifying the problem at hand. There are too many complexities associated with the problem to be encapsulated in a single component like theDropbox component
(or many). I might just end up creating 100+ ng-templates (or different components) if I go the route of creating a template for each use-case.