简体   繁体   English

Angular JS转发器+ Bootstrap Carousel

[英]Angular JS repeater + Bootstrap Carousel

I'm trying to fill a Bootstrap Carousel component with data from AngularJS. 我正在尝试使用AngularJS中的数据填充Bootstrap Carousel组件。 Basically I'm filling the items inside carousel-inner class like this: 基本上我正在填充carousel-inner类中的项目,如下所示:

 <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. 哪个可以正常工作,但起初我看不到任何图片,我认为这是因为我的项目都没有active类。

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. 第一个div有“活动”类,它是可见的,当我尝试编写没有像上面的Angular JS这样的例子时,它可以工作。

How can I set the first item from ng-repeat to have the "active" class? 如何将ng-repeat中的第一项设置为“活动”类?

Use 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. 在这里,您可以看到在本地范围上公开了哪些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM