我想使用 Bootstrap 4 和 Angular 6 创建轮播,一切正常,但我有一个问题。我想使用 *ngFor 循环动态添加指示器,我的问题是属性 data-slide-to
的数字必须等于照片的数量。我用循环添加这个,所以我想从索引值传递 i
。链接不起作用,在我的浏览器中我在每张照片中看到 data-slide-to = "i"
如何将数据绑定(bind)到此属性?
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" *ngFor="let li of sliderImages; let i = index" data-slide-to="i" [ngClass]="{'active' : i == 0}"></li>
</ol>
我尝试过 [data-slide-to]
和 data-slide-to = "{{i}}"
但这些会引发错误。
最佳答案
您似乎正在寻找以下语法之一:
[attr.data-slide-to]="i"
或
attr.data-slide-to="{{i}}"
关于angular - Bootstrap 4 轮播与 Angular 6 - ngFor 中的 Ol 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50907896/