我想在使用ngFor迭代时跳过item对象中的Date & Microsite键和值。所以对于ngIf是不起作用的。
这是我的模板
<table *ngIf="!emptyQueries">
<thead>
<th>Date</th>
<th>Microsite</th>
<th><div class="w-50 d-inline-block" >Query</div><div class="w-50 d-inline-block">Answer</div></th>
</thead>
<tbody *ngFor="let item of queries">
<td class="align-top">{{item?.Date}}</td>
<td class="align-top">{{item?.Microsite}}</td>
<td class="align-top">
<table>
<tbody>
<tr *ngFor="let entry of item | keyvalue">
<td class="w-50 align-top pt-0" *ngIf="entry.key != 'Date' || entry.key !='Microsite'">{{entry.key}}</td>
<td class="w-50 align-top pt-0" *ngIf="entry.key != 'Date' || entry.key !='Microsite'">{{entry.value}}</td>
</tr>
</tbody>
</table>
</td>
</tbody>
</table>这是实际的输出

你知道怎么解决这个问题吗?谢谢
发布于 2019-09-11 21:05:44
用&&替换||
*ngIf="entry.key != 'Date' && entry.key !='Microsite'"发布于 2019-09-11 21:10:07
你可以在typescript中使用析构来完成它,如下所示:
const {Date, Microsite, ...filtredItem} = item;然后在不使用if的情况下在模板中使用filtredItem
https://stackoverflow.com/questions/57889858
复制相似问题