使bootstrap轮播指示器无法点击

时间:2015-12-16 15:29:57

标签: javascript angularjs twitter-bootstrap-3

我正在使用tweeters bootstrap Carousel,我不希望我的用户能够切换幻灯片,我想根据自己的逻辑切换幻灯片。我已完全删除了控件,但我仍想显示幻灯片指示器。

我该怎么做?

角度解决方案更可取。

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用template-url属性指定要用于轮播的自定义模板。复制默认模板并删除不需要的元素和事件。

默认模板:

<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()">
  <div class="carousel-inner" ng-transclude></div>
  <a role="button" href class="left carousel-control" ng-click="prev()" ng-show="slides.length > 1">
    <span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span>
    <span class="sr-only">previous</span>
  </a>
  <a role="button" href class="right carousel-control" ng-click="next()" ng-show="slides.length > 1">
    <span aria-hidden="true" class="glyphicon glyphicon-chevron-right"></span>
    <span class="sr-only">next</span>
  </a>
  <ol class="carousel-indicators" ng-show="slides.length > 1">
    <li ng-repeat="slide in slides | orderBy:indexOfSlide track by $index" ng-class="{ active: isActive(slide) }" ng-click="select(slide)">
      <span class="sr-only">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if="isActive(slide)">, currently active</span></span>
    </li>
  </ol>
</div>

编辑后的版本,删除了左右按钮和被动页面指示符:

<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()">
  <div class="carousel-inner" ng-transclude></div>
  <ol class="carousel-indicators" ng-show="slides.length > 1">
    <li ng-repeat="slide in slides | orderBy:indexOfSlide track by $index" ng-class="{ active: isActive(slide) }">
      <span class="sr-only">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if="isActive(slide)">, currently active</span></span>
    </li>
  </ol>
</div>

创建一个包含上述标记的新.html文件(或使用template cache),并将template-url="[your file].html"添加到<uib-carousel>元素。