javascript - UI Bootstrap control uib-carousel with custom buttons -
i trying control carousel through buttons, rather controls above carousel (i hiding chevron icons).
i inspected chevron icon , found in source:
<a role="button" href="" class="left carousel-control" ng-click="prev()" ng-class="{ disabled: isprevdisabled() }" ng-show="slides.length > 1"> <span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">previous</span> </a>
i tried adding attributes (except class) button, not work:
<button type="button" class="btn btn-default btn-block" ng-click="prev()" ng-class="{ disabled: isprevdisabled() }" ng-show="slides.length > 1">previous</button>
- i guessing not work because button not within uib-carousel, not know 'prev()' , 'isprevdisabled()' functions are. can reference function, or create own control it?
another thing noticed, off-topic, if double-click either right or left chevron button (let's right), goes 1 slide right. , if click left chevron, moves right once , moves left (when click left chevron 2nd time). way resolve 'issue'? should either move 2 slides on double-click, or discard 2nd click , when opposite direction clicked, perform action properly.
the better way use template-url attribute , define own carousel controls way. i've done project (although stuck on getting next button fire custom event in controller well).
<div class="col-xs-12 box-shadow" style="height: 50px; padding-top: 11px; background-color: #fff; z-index: 15;">step {{ autoseq.wizardstep + 1 }} of 5</div> <uib-carousel template-url="/tpl.html" active="autoseq.wizardstep" no-wrap="true" on-carousel-next="autoseq.onnext()" style="height: 395px;"> <uib-slide style="height: 395px; margin-top: 5px;" index="0"> ...slide content.. </uib-slide> </uib-carousel>
and template defined such (in same html file)
<script type="text/ng-template" id="/tpl.html"> <div class="carousel"> <div class="carousel-inner" ng-transclude></div> <div class="carousel-controls"> <div class="carousel-control" style="display: table-cell; float: left; width: 30%;"> <a role="button" href class="left chevron-left" ng-click="prev()" ng-class="{ disabled: isprevdisabled() }" ng-show="slides.length > 1"> <i class="fa fa-chevron-left"></i> <span style="margin-left:5px;">back</span> </a> </div> <div style="display: table-cell; float: left; width: 40%;"> <ol class="carousel-indicators" ng-show="slides.length > 1"> <li ng-repeat="slide in slides | orderby:indexofslide track $index" ng-class="{ active: isactive(slide) }"> </li> </ol> </div> <div class="carousel-control" style="display: table-cell; float: left; width: 30%;"> <a role="button" href class="right chevron-right" ng-click="next()" ng-class="{ disabled: isnextdisabled() }" ng-show="slides.length > 1"> <span style="margin-right:5px;">next</span> <i class="fa fa-chevron-right"></i> </a> </div> </div> </div> </script>
Comments
Post a Comment