Am Struggling lot to complete my task as newly started into Angular CDK DragnDrop. When trying to drag the image item and drop into location, I got Cannot read properties of undefined (reading 'length') .
Not sure this is because of different Interface against Angular DragnDrop CDK
drop(event: CdkDragDrop<any>) {
if (event.previousContainer === event.container) {
moveItemInArray(
event.container.data,
event.previousIndex,
event.currentIndex
);
} else {
transferArrayItem(
event.previousContainer.data,
event.container.data, // getting undefined here
event.previousIndex,
event.currentIndex
);
console.log(
'transferArrayItem',
event.container.data.colorways
);
const formArry = this.myDivName;
formArry.insert(0, this.fb.control(event.container.data));
}
}
does event.container.data, pointing to drop location or source location?
Here you go
Working Stackblitz