Answer the question
In order to leave comments, you need to log in
How to display a table element in an angular material table with certain conditions?
I have an array of objects:
[
{name: 'some1', tasks: [{taskname: 'tasksome1', status: 'finished' }, {taskname: 'tasksome2', status: 'finished' }] },
{name: 'some2', tasks: [{taskname: 'tasksome3', status: 'started' }, {taskname: 'tasksome4', status: 'finished' }] },
]
<ng-container matColumnDef="tasks">
<th mat-header-cell *matHeaderCellDef> Задачи </th>
<td mat-cell *matCellDef="let element"> {{element.taskname}} </td>
</ng-container>
Answer the question
In order to leave comments, you need to log in
You need to use the ngIf directive like so:
<ng-container matColumnDef="tasks">
<th mat-header-cell *matHeaderCellDef> Задачи </th>
<td
mat-cell *matCellDef="let element"
*ngIf="element.status === started"
> {{element.taskname}} </td>
</ng-container>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question