title: Angular. How to pass dynamic conponent to mat-table cell?
body: <p>I have this column config for material table:</p>
  
  <pre><code>columns = [
      { columnDef: 'firstName', header: 'FirstName',    cell: (user) =&gt; `${user.firstName}` },
      { columnDef: 'lastName',     header: 'LastName',   cell: (user) =&gt; `${user.lastName}`     },
      { columnDef: 'mobile',   header: 'Mobile', cell: (user) =&gt; `${user.mobile}`   },
      { columnDef: 'email',   header: 'Email', cell: (user) =&gt; `${user.email}`   },
    ];
  </code></pre>
  
  <p>And i want to make mat table throught ngFor cycle, like this:</p>
  
  <pre><code>&lt;mat-table #table [dataSource]="dataSource"&gt;
  
      &lt;ng-container *ngFor="let column of columns" [cdkColumnDef]="column.columnDef"&gt;
        &lt;mat-header-cell *cdkHeaderCellDef&gt;{{ column.header }}&lt;/mat-header-cell&gt;
        &lt;mat-cell *cdkCellDef="let row"&gt;{{ column.cell(row) }}&lt;/mat-cell&gt;
      &lt;/ng-container&gt;
      &lt;mat-header-row *matHeaderRowDef="displayedColumns"&gt;&lt;/mat-header-row&gt;
      &lt;mat-row *matRowDef="let row; columns: displayedColumns;"&gt;&lt;/mat-row&gt;
    &lt;/mat-table&gt;
  </code></pre>
  
  <p>Everything is fine, but what if i want to pass some html template or component in table cell, for example if i want column, where will be button to open user-edit dialog.</p>
  
  <p>I've tried in this way:</p>
  
  <pre><code>  &lt;mat-cell *cdkCellDef="let row" [innerHTML]="&lt;test-component&gt;&lt;/test-component&gt; | safeHTML"&gt;&lt;/mat-cell&gt;
  </code></pre>
  
  <p>and the component:</p>
  
  <pre><code>@Component({
    selector: 'test-component',
    template: `  
        &lt;button (click)="openEditDialog()"&gt;test&lt;/button&gt;
    `,
  })
  export class TestComponent implements OnInit {
  </code></pre>
  
  <p>And it works, but i can't use data binding and, for example put some data to component through @Input.
  What am doing wrong or maube there is another approach to achieve it?
  Would be appreciate for any advice)</p>