【发布时间】:2020-10-23 15:39:33
【问题描述】:
我正在尝试使用 ngFor 在引导选项卡上循环,它会显示所有选项卡,因为活动类也是循环的,我如何默认只显示第一个选项卡 但是,导航选项卡工作正常。 我需要的是: 使用每个活动导航链接的活动类循环选项卡窗格
HTML
<section id="new-recipes">
<div class="recipes-title">
<h1>NEW RECIPES</h1>
</div>
<div class="recipe-tabs">
<div class="row">
<div class="col-sm-2">
<div
class="nav flex-column nav-pills"
id="v-pills-tab"
role="tablist"
aria-orientation="vertical"
>
<a
class="nav-link"
*ngFor="let tab of sections.recipes"
id="v-pills-home-tab"
data-toggle="pill"
href="#v-pills-{{ tab.id }}"
role="tab"
aria-controls="v-pills-home"
aria-selected="true"
>{{ tab.category.title }}
</a>
</div>
</div>
</div>
</div>
<div class="recipe-body">
<div class="row h-100">
<div class="col-12">
<div
class="tab-content h-100"
id="v-pills-tabContent"
*ngFor="let recipe of sections.recipes"
>
<div
class="tab-pane h-100 fade show active"
id="v-pills-{{ recipe.id }}"
role="tabpanel"
aria-labelledby="v-pills-home-tab"
>
<div class="row no-gutters h-100">
<div class="col-sm-3">
<div class="recipe-description">
<h4>{{ recipe?.title }}</h4>
<p
class="text-white e2e-inner-html-bound"
[innerHTML]="recipe.description"
></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
【问题讨论】:
-
请创建一个 stackblitz 链接