move dashboard elements and store the order
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {CdkDragDrop, moveItemInArray, transferArrayItem} from '@angular/cdk/drag-drop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-customizable-grid',
|
||||
templateUrl: './customizable-grid.component.html'
|
||||
})
|
||||
export class CustomizableGridComponent {
|
||||
todo = ['Get to work', 'Pick up groceries', 'Go home', 'Fall asleep'];
|
||||
done = ['Get up', 'Brush teeth', 'Take a shower', 'Check e-mail', 'Walk dog'];
|
||||
|
||||
drop(event: CdkDragDrop<string[]>) {
|
||||
if (event.previousContainer === event.container) {
|
||||
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
|
||||
} else {
|
||||
transferArrayItem(
|
||||
event.previousContainer.data,
|
||||
event.container.data,
|
||||
event.previousIndex,
|
||||
event.currentIndex,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user