How to implement bootstrap corousel with angular ng-repeat?

冷暖自知 提交于 2020-08-11 19:04:06

问题


When I am trying to use ng-repeat inside corousel-inner the corousel is not working properly, how to use carousel with ng-repeat ?


回答1:


Not exact but seems like what you want.

<div class="container" ng-show="ifImages">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators" ng-repeat="image in images">
        <li data-target="#myCarousel" data-slide-to="$index" ng-class="{'active': $index == 0}"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox" ng-repeat="image in images">
        <div class="item" ng-class="{'active': $index == 0}">
            <img bn-lazy-src="{{image.fullPath}}" title="{{image.description}}" alt="missing" />
            <div class="carousel-caption">
                <h3>{{image.name}}</h3>
                <p>{{image.description}}</p>
            </div>
        </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>



来源:https://stackoverflow.com/questions/40086381/how-to-implement-bootstrap-corousel-with-angular-ng-repeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!