下面是我的部分angular2组件模板html。“ searchTickets $”是对象数组的Observable。
<table class="table table-condensed" *ngIf="searchTickets$">
<thead>
<tr>
<th><h3>Ticket ID</h3></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ticket of searchTickets$ | async">
<td><small>{{ticket.ticketID}}</small></td>
</tr>
</tbody>
</table>
我的意图是仅在可观察到的返回1个或更多记录时才显示该表。
需要在* ngIf条件中进行修改才能使其实现。
你应该试试
<table class="table table-condensed" *ngIf="(searchTickets$ | async)?.length > 0">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句