import { Component, OnInit } from '@angular/core';
import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop';
@Component({
selector: 'kt-menu-management',
templateUrl: './menu-management.component.html',
styleUrls: ['./menu-management.component.scss']
})
export class MenuManagementComponent implements OnInit {
constructor() { }
ngOnInit() {
}
items = [
{
id:1, name:'Appetizer'
},
{
id:2, name:'Main Course'
}
]
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.items, event.previousIndex, event.currentIndex);
}
}
Sample demo available here : https://stackblitz.com/angular/omybvaablxk?file=src%2Fapp%2Fcdk-drag-drop-custom-placeholder-example.ts
**Looking for guidance on implementing Angular drag and drop functionality for an array of objects. I've tried it with an array of strings successfully, but not with an array of objects. Attempts using interfaces have also been unsuccessful. Any suggestions?
**