我有两个结构不同的JSON数组;看起来像这样:
divisions:
{
title: string,
text: string
}[],
和:
featureSection:
{
headingName: string,
features: string[]
}[]
我需要创建看起来像DIV的DIV:
<div id="highlight-features" class="py-5 " *ngFor="let data of retrievedDATA.responseJSON.divisions; let odd=odd; let index = index let even=even" [ngClass]="{ 'bg-white': odd, 'bg-light-secondary': even }">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2>{{ data.title }}</h2>
<br>
<p class="lead">{{ data.text }}</p>
</div>
</div>
</div>
和(对于功能部分):
<div id="featureDiv" class="py-5 bg-light-secondary">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto" *ngFor="let features of retrievedDATA.responseJSON.featureSection">
<h2>{{ features.headingName }}</h2>
<br>
<ul>
<li *ngFor="let feature of features.features">{{ feature }}</li>
</ul>
</div>
</div>
</div>
我面临的问题是要使两组ngFor的奇偶bg-white和bg-light-secondary保持一致,因为除法和featureSections的数量可以随时更改。我想知道是否可以将上一个em的索引传递给下一个ngFor我可以使其正常工作,但我无法弄清楚如何传递索引