title: Trying to clear Angular 8 CDK Drag and Drop List
body: <p>I'm making a simple drag and drop list with Angular and can't figure out how to reset the tables to their starting arrangements. I was trying to use transferArrayItem but I don't know how to reference the table to get access to the items in the list.</p>
  
  <pre><code>&lt;div class="container"&gt;
  &lt;h2&gt;Groceries&lt;/h2&gt;
  
  &lt;div cdkDropList #todoList="cdkDropList" [cdkDropListData]="todo"
    [cdkDropListConnectedTo]="doneList" class="list" (cdkDropListDropped)="drop($event)"&gt;
  &lt;div class="list-item" *ngFor="let item of todo" cdkDrag&gt;{{item}}&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container"&gt;
  &lt;h2&gt;Cart&lt;/h2&gt;
  
  &lt;div cdkDropList #doneList="cdkDropList" [cdkDropListData]="done"
   [cdkDropListConnectedTo]="todoList" class="list" (cdkDropListDropped)="drop($event)"&gt;
  &lt;div class="list-item" *ngFor="let item of done" cdkDrag&gt;{{item}}&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="buttons"&gt;
  &lt;button id="clearCart" (click)="clearCart()"&gt;Clear Cart&lt;/button&gt;
  &lt;button id="checkout" (click)="checkout()"&gt;Checkout&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my "groceries.component.html" file where the lists are located and defined. And below is my "groceries.component.ts" file where the functions are ran.</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
  
  @Component({
  selector: 'app-groceries',
  templateUrl: './groceries.component.html',
  styleUrls: ['./groceries.component.css'],
  })
  export class GroceriesComponent {
  todo = [
  'Apple',
  'Banana',
  'Avocado',
  'Cheez-Its',
  'Doritos',
  'Gushers',
  'Orange',
  'Big ol steaks'
  ];
  
  done = [
  ];
  
  drop(event: CdkDragDrop&lt;string[]&gt;) {
  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);
  }
  }
  
  clearCart(){
  
  
  window.alert("Cart has been cleared!");
  }
  
  exit(){
  
  }
  
  checkout(){
  window.alert("Don't worry about paying, we'll ship them right now!");
  }
  }
  </code></pre>
  
  <p>I was going to use the exit() method to reset the elements back to original positions but still run into the problem of not knowing how to access the information of the items in the "done" array.</p>
  
  <p>Also it's worth noting that I'm exploring into Angular for the first time, the "todo" and "done" lists were autogenerated and I plan on changing the names when I get the functionality working.</p>