SHARE
TWEET

Untitled

a guest Dec 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import {CdkDragDrop, moveItemInArray, transferArrayItem} from '@angular/cdk/drag-drop';
  3.  
  4. @Component({
  5.   selector: 'app-root',
  6.   templateUrl: './app.component.html',
  7.   styleUrls: ['./app.component.scss']
  8. })
  9. export class AppComponent {
  10.  
  11.   todos: string[] = [
  12.     'Get eggs from grocery store',
  13.     'Change the oil & filter in car',
  14.     'Do the dishes',
  15.     'Pay the utility bill'
  16.   ];
  17.  
  18.   completed: string[] = [
  19.     'Wash the car',
  20.     'Respond to InMail'
  21.   ];
  22.  
  23.   drop(event: CdkDragDrop<string[]>) {
  24.    
  25.     if(event.previousContainer === event.container) {
  26.      
  27.       moveItemInArray(
  28.         event.container.data,
  29.         event.previousIndex,
  30.         event.currentIndex
  31.       );
  32.  
  33.     } else {
  34.      
  35.       transferArrayItem(
  36.         event.previousContainer.data,
  37.         event.container.data,
  38.         event.previousIndex,
  39.         event.currentIndex
  40.       );
  41.  
  42.     }
  43.   }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top