我在这里有此代码:
<div *ngFor="let condition of interior_conditions; let i = index" class="condition-item-2">
<div class="condition-title">{{condition.name}}</div>
<div class="condition-content">
<div class="row">
<hr class="my-hr">
<div class="col-12">
<span *ngFor="let zone of zones">
<span *ngFor="let poor_condition of zone.poor_conditions">
<span *ngIf="poor_condition._id==condition._id" class="danger_zones">
<span>
Danger Zones:
</span>
{{zone.name}}
</span>
</span>
</span>
</div>
</div>
</div>
</div>
事情是这样的:
有什么想法吗?
答案 0 :(得分:0)
假设您无法或不希望将跨度移动到循环之外,则可以基于索引添加一个ngIf
:
<span *ngIf="i === 0"></span>
答案 1 :(得分:0)
您应该移动标题为“危险区域”的跨度。
<div *ngFor="let condition of interior_conditions; let i = index" class="condition-item-2">
<div class="condition-title">{{condition.name}}</div>
<div class="condition-content">
<div class="row">
<hr class="my-hr">
<div class="col-12">
<span *ngFor="let zone of zones">
<span>
Danger Zones:
</span>
<span *ngFor="let poor_condition of zone.poor_conditions">
<span *ngIf="poor_condition._id==condition._id" class="danger_zones">
{{zone.name}}
</span>
</span>
</span>
</div>
</div>
</div>
</div>
答案 2 :(得分:0)
我认为唯一可行的方法是通过服务,其中函数将输入条件并返回条件差的区域