ng-class或ng-style指令在ui bootstap轮播中不起作用

时间:2016-01-22 07:30:57

标签: angularjs angularjs-directive angular-ui-bootstrap

我正在使用UI Bootstrap Carousel并需要在其中进行一些自定义,以便用户可以访问配置选项,如文本颜色,导航显示/隐藏等....

为此我已经使用了他们的carousel html模板并添加了一些ng-class用于display block / none和其他一些ng-style但是那些不起作用并且对它们没有任何影响。

如果我在写有轮播标记的页面上使用相同的文件,这些工作正常。

请参阅plunker复制问题

Carousel Plunker

模板HTML

<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" ng-class="{'dispNone': carousel.arrow}">
        <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" ng-class="{'dispNone': carousel.arrow}">
        <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>

1 个答案:

答案 0 :(得分:1)

您可以在模板中使用$ parent,因为您有不同的范围。喜欢

$parent.navArrow