2

<ons-carousel swipeable overscrollable auto-scroll fullscreen 
              auto-scroll-ratio="0.2" var="carousel" style="position:initial" 
              on-carousel-change="selected($index)">            
</ons-carousel>

how can I call my function?

Starscream1984
  • 3,072
  • 1
  • 19
  • 27
  • I have fixed the duplicated code snippet and made it more readable, but the question is still lacking clear explanation of what the problem is. – Starscream1984 Mar 02 '16 at 14:46

2 Answers2

1

ons-carousel fires a postchange event every time it changes. You can listen for it and run your function.

If you use AngularJS with Onsen UI (I guess you do since you have var attribute), you can specify a handler for this event directly with ons-postchange attribute: ons-postchange="myHandler($event, myData)".

Fran Dios
  • 3,482
  • 2
  • 15
  • 26
1

For AngularJS, Onsen only supports this event model: ons-postchange. on-carousel-change is not a valid event and as such is not supported by ons-carousel.

Working examples and explanations are posted here:

Onsen 1.x - https://onsen.io/reference/ons-carousel.html

Onsen 2 - https://onsen.io/2/reference/ons-carousel.html

Munsterlander
  • 1,356
  • 1
  • 16
  • 29