【问题标题】:Bootstrap 4 carousel with Angular 6 - Ol links in ngFor带有 Angular 6 的 Bootstrap 4 轮播 - ngFor 中的 Ol 链接
【发布时间】:2018-11-27 04:57:57
【问题描述】:

我想用 Bootstrap 4 和 Angular 6 创建轮播,一切正常,但我有一个问题。我想用 *ngFor 循环动态添加指标,我的问题是属性data-slide-to 的数字必须等于照片的数量。我用循环添加这个,所以我想从索引值传递i。链接不起作用,在我的浏览器中,我在每张照片中都看到了 data-slide-to = "i"

如何将数据绑定到该属性??

<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}}",但这些都会让我出错。

【问题讨论】:

    标签: angular html bootstrap-4


    【解决方案1】:

    您似乎正在寻找以下语法之一:

    [attr.data-slide-to]="i"
    

    attr.data-slide-to="{{i}}"
    

    【讨论】:

    • 是的 :) 我忘记了,非常感谢!
    • @yurzul 你能帮我THIS
    猜你喜欢
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 2019-11-22
    • 1970-01-01
    • 2017-07-17
    相关资源
    最近更新 更多