import { Component } from '@angular/core' ; import { CdkDragDrop , moveItemInArray , transferArrayItem } from '@angular/cdk/drag-drop' ; title @ Component ( { selector : 'cdk-drag-drop-connected-sorting-example' , templateUrl : 'cdk-drag-drop-connected-sorting-example.html' , styleUrls : [ 'cdk-drag-drop-connected-sorting-example.css' ] , } ) export class CdkDragDropConnectedSortingExample { 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 ) { 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 ) ; } } }