此模板示例
<div *ngFor="let order of orders" class="col-1-4">
<tr *ngIf="order.user_id===user">
<td> {{ order.package_id }} </td>
<td> <img src="{{order.img}}" width="100" height="120"></td>
<td>{{ order.name }}</td>
<td>{{ order.price }}</td>
<td>{{ order.size_i }}</td>
<td>{{ order.size_s }}</td>
<td>{{ order.color }}</td>
<td>{{ order.count }}</td>
<td>{{ order.order_date | date}}</td>
<td>{{ order.price * cnt | currency:'KRW' }}</td>
</tr>
</div>
答案 0 :(得分:2)
尝试使用ng-container
将不会呈现任何html,并且如果tr
解析为*ngIf
true
元素将可见。
<ng-container *ngFor="let order of orders">
<tr *ngIf="order.user_id===user">
<td> {{ order.package_id }} </td>
<td> <img src="{{order.img}}" width="100" height="120"></td>
<td>{{ order.name }}</td>
<td>{{ order.price }}</td>
<td>{{ order.size_i }}</td>
<td>{{ order.size_s }}</td>
<td>{{ order.color }}</td>
<td>{{ order.count }}</td>
<td>{{ order.order_date | date}}</td>
<td>{{ order.price * cnt | currency:'KRW' }}</td>
</tr>
</ng-container>