admin管理员组文章数量:1279055
I'm trying to fill a Bootstrap Carousel ponent with data from AngularJS.
Basically I'm filling the items inside carousel-inner
class like this:
<div class="carousel-inner">
<div class="item" ng-repeat="screen in app.screens">
<img ng-src="screens/{{screen}}" class="center"/>
</div>
</div>
Which would work fine, but at first I cannot see any picture, I think it's because none of my items has the active
class.
In the official documentation:
<div class="carousel-inner">
<div class="active item">…</div>
<div class="item">…</div>
<div class="item">…</div>
</div>
The first div has "active" class, and it is visible, and when I try to write my example without Angular JS like above, it works.
How can I set the first item from ng-repeat to have the "active" class?
I'm trying to fill a Bootstrap Carousel ponent with data from AngularJS.
Basically I'm filling the items inside carousel-inner
class like this:
<div class="carousel-inner">
<div class="item" ng-repeat="screen in app.screens">
<img ng-src="screens/{{screen}}" class="center"/>
</div>
</div>
Which would work fine, but at first I cannot see any picture, I think it's because none of my items has the active
class.
In the official documentation:
<div class="carousel-inner">
<div class="active item">…</div>
<div class="item">…</div>
<div class="item">…</div>
</div>
The first div has "active" class, and it is visible, and when I try to write my example without Angular JS like above, it works.
How can I set the first item from ng-repeat to have the "active" class?
Share Improve this question asked Apr 22, 2013 at 20:38 AxarydaxAxarydax 16.6k22 gold badges95 silver badges154 bronze badges1 Answer
Reset to default 12Use the following:
<div class="item" ng-repeat="screen in app.screens" ng-class="{active : $first}">
Here you can see which properties are exposed on the local scope.
本文标签: javascriptAngular JS repeaterBootstrap CarouselStack Overflow
版权声明:本文标题:javascript - Angular JS repeater + Bootstrap Carousel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741221065a2360980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论