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.
MatColumnDef extends CdkColumnDefDefines a set of cells available for a table column.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With