当显示某个Carousel项目时,有没有办法触发事件?
下面我给出了一个代码示例,并希望在显示最后一项时执行doSomething()函数:
<ons-template id="carrossel1.html">
<ons-page ng-controller="CarrosselController">
<ons-carousel fullscreen swipeable overscrollable auto-scroll>
<ons-carousel-item ng-repeat="item in [1,2,3,4]" id="item{{item}}">
Carousel Item {{item}} {{html}}
</ons-carousel-item>
<ons-carousel-item ng-repeat="item in [1]">
FINAL (when this is show, I need to execute doSomething() function)
</ons-carousel-item>
</ons-carousel>
</ons-page>
</ons-template>
&#13;
怎么做?
TKS
答案 0 :(得分:1)
Carousel methods here。您可以将on(eventName, listener)
与事件postchange
一起使用。每次更改轮播时都会触发,然后在监听器中只需检查哪个索引处于活动状态getActiveCarouselItemIndex()
。
希望它有所帮助!