Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data-Slide-to bootstrap binding Angular 2

Tags:

html

angular

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>
like image 523
Daniel García Avatar asked Nov 28 '22 22:11

Daniel García


2 Answers

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

like image 75
ChinhNV Avatar answered Dec 06 '22 13:12

ChinhNV


Try this

data-slide-to -----> [attr.data-slide-to]

like image 36
WinMaker Avatar answered Dec 06 '22 13:12

WinMaker