title: Can't get the Datatable Instance from a ViewChild
body: <p>When I attempt to access the <code>dtInstance</code> of my DataTable ViewChild I get this error:</p>
  
  <blockquote>
    <p>ERROR TypeError: Cannot read property 'then' of undefined</p>
  </blockquote>
  
  <p>Declaring ViewChild in component:</p>
  
  <pre><code>@ViewChild('dtuser') dtuser: DataTableDirective;
  </code></pre>
  
  <p>Method that destroys the datatable instance:</p>
  
  <pre><code>searchByCoid(term: string): void {
  console.log("user: ",this.dtuser);
  
  this.dtuser.dtInstance.then((dtInstance: DataTables.Api) =&gt; {dtInstance.destroy();});
  this.getUsersByCoid(term.trim());
  //this.getLoggedInCompanies(); 
  }
  </code></pre>
  
  <p>The output of the Datatable object into console (when calling the method above):</p>
  
  <pre><code>user:  
  ElementRef {nativeElement: table#DataTables_Table_0.row-border.hover.dataTable.no-footer}
  nativeElement
  :
  table#DataTables_Table_0.row-border.hover.dataTable.no-footer
  __proto__
  :
  Object
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table #dtcompany datatable [dtOptions]="dtOptionsComp" [dtTrigger]="dtTriggerCompany" class="row-border hover"&gt;
      &lt;thead&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
      &lt;tbody&gt;
      &lt;tr *ngFor="let d of companylist" (click)="selectCompany($event, d)" [class.highlighted]="d.highlighted"&gt;
      &lt;td&gt;{{d.id}}&lt;/td&gt;&lt;td&gt;{{d.name}}&lt;/td&gt;
    &lt;/tr&gt;&lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;h1&gt;Select User to Modify&lt;/h1&gt;
  &lt;table #dtuser datatable [dtOptions]="dtOptionsUser" [dtTrigger]="dtTriggerUser" class="row-border hover"&gt;
      &lt;thead&gt;&lt;tr&gt;&lt;th&gt;First Name&lt;/th&gt;&lt;th&gt;Last Name&lt;/th&gt;&lt;th&gt;Company ID&lt;/th&gt;&lt;th&gt;User ID&lt;/th&gt;&lt;th&gt;PAIOS Acct ID&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
      &lt;tbody&gt;
    &lt;tr *ngFor="let c of userlist"&gt;
      &lt;td&gt;{{c.firstname}}&lt;/td&gt;&lt;td&gt;{{c.lastname}}&lt;/td&gt;&lt;td&gt;{{c.companyId}}&lt;/td&gt;&lt;td&gt;{{c.user_id}}&lt;/td&gt;&lt;td&gt;{{c.PAIOS_acctid}}&lt;/td&gt;
    &lt;/tr&gt;&lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>