Display custom message if data[col.field] is empty
Posted: 12 Apr 2021, 19:37
Hi everyone !
Here is the code I'll talk about :
This is a table with rows representing college thesis. One column for example, has the Header "Keyword".
Let's say, in my content[col.field], there are no keywords at all. In the current state, the column will just be blank.
But I'd like to have a random message saying "empty" if there is nothing to show.
I've tried :
This doesn't work, and I can't find anywhere a correct way to do that, based on content[col.field] in my case.
Any help would be welcomed !
Here is the code I'll talk about :
Code: Select all
<ng-template pTemplate="body" let-content let-columns="columns">
<tr [pSelectableRow]="content" (dblclick)="onDoubleClick(content)">
<td *ngFor="let col of columns">
{{ content[col.field] }}
</td>
</tr>
</ng-template>
Let's say, in my content[col.field], there are no keywords at all. In the current state, the column will just be blank.
But I'd like to have a random message saying "empty" if there is nothing to show.
I've tried :
Code: Select all
{{ content[col.field] !== ' ' ? content[col.field] : 'empty' }}
Any help would be welcomed !