Reputation: 61
Is it posibble to bind index property of *ngFor directive of Angular to some attribute that isnt part of native html?
<ol class="carousel-indicator">
<li data-target="#myCarousel" data-slide-to="{{i}}" *ngFor="let item of items; let i = index></li>
</ol>
Upvotes: 5
Views: 5482
Reputation: 39
use v-bind:data-slide-to="index"
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators"
v-for="(image, index) in images" v-bind:key="index"
v-bind:data-slide-to="index"
:class="{'active' : index===0}"></li>
</ol>
Upvotes: 1
Reputation: 351
Please edit to:
<li *ngFor="let banner of banners,let i = index" data-target="#carousel" class="{{ (i == 0) ? 'active' : '' }}" attr.data-slide-to="{{i}}"></li>
* edit: attr.data-slide-to="{{i}}" => Success
Upvotes: 21
Reputation: 815
try this code
<ol class="carousel-indicator">
<li data-target="#myCarousel" [data-slide-to]="i" *ngFor="let item of items; let i = index></li>
</ol>
data-slide-to="i"
-> [data-slide-to]="i"
Upvotes: -1