Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular show image in Material Table Cell

I try to show an image in a cell of my Material table. Therefore I tried this code in my HTML File:

<ng-container matColumnDef="ImageUrl">
  <mat-header-cell *matHeaderCellDef> imageUrl </mat-header-cell>
  <mat-cell *matCellDef="let element"> {{element.imageUrl}} </mat-cell>
  <img [src]="imageUrl" />
</ng-container>

Unfortunately, nothing appears in my Table.

like image 571
Dominik Avatar asked Feb 09 '19 20:02

Dominik


People also ask

What is MatColumnDef?

MatColumnDef extends CdkColumnDefDefines a set of cells available for a table column.


1 Answers

Give this a try:

<ng-container matColumnDef="imageUrl">
  <th mat-header-cell *matHeaderCellDef> Image Url </th>
  <td mat-cell *matCellDef="let element"> <img [src]="element.imageUrl" /> </td>
</ng-container>

Here's a Working Sample StackBlitz for your ref.

like image 193
SiddAjmera Avatar answered Sep 18 '22 04:09

SiddAjmera