ngFor手风琴中的手风琴

问题描述 投票:0回答:1

我有一个ngFor,对于每个项目,我都有一个按钮来显示一些其他详细信息(我正在使用自举式手风琴)。我的问题是我只想打开有关当前商品的手风琴(不是全部)。

我将向您展示我尝试使用该索引的方法,但是它不起作用。

这是我的ngFor:

<ul *ngFor="let star of stars; index as i;">
...
</ul

这是我的按钮:

<button type="button" data-toggle="collapse" attr.[data-target]="'collapse' + i" aria-expanded="false"></button>

这是手风琴:

<div class="collapse" [id]="'collapse' + i">
<div class="card card-body">
...

这是我的错误:

ERROR DOMException: Failed to execute 'setAttribute' on 'Element': 'attr.[data-target]' is not a valid attribute name.

您能帮我吗?谢谢!

angular bootstrap-4 accordion ngfor
1个回答
0
投票

尝试一下:

<div class="collapse" [attr.id]="'collapse' + i">

<button type="button" data-toggle="collapse" [attr.data-target]="'collapse' + i" aria-expanded="false"></button>

如果这不是您想要的,那么进行堆叠闪电射击会很不错:-)

© www.soinside.com 2019 - 2024. All rights reserved.