Monaca Onsen UI Discord Chat Github Repo

carousel.setActiveCarouselItemIndex(index) not working in OnsenUI 2.0 with Angular 1

  • I’ve spent a few days trying to figure out what is wrong via documentation - this should work easily out of the box but seems that something more fundamental is causing the issue…

    How to recreate the issue

    1. Created a new project from the templates on Monaca - Onsen UI 2.0 with Angular 1.
    2. Loaded the OnsenUI 2.0 theme and Monaca JQuery latest version from CSS/JS components
    3. Created a carousel and a button to change the carousel index
    4. Carousel does not change when button is clicked.
    5. When button is clicked, console log shows that setActiveCarouselItemIndex is not a function
    6. However, works fine

    Here’s my code:

        <ons-button ng-click="carousel.setActiveCarouselItemIndex(2)">Push Carousel</ons-button>
        <ons-carousel style="height:100%;width:100%;" var="carousel" swipeable overscrollable auto-scroll>
            <ons-carousel-item>Page 1 </ons-carousel-item>
            <ons-carousel-item>Page 2 </ons-carousel-item>
            <ons-carousel-item>Page 3</ons-carousel-item>

  • Onsen UI

    @kkng_88 If you are using the Release Candidate you have to change your method and use setActiveIndex. It’s in the docs here.

    Did you find a place in the docs where it’s not updated?

  • Thanks Fran, that certainly did work…
    However, the documentation does not seem to be updated in anyway to reflect that.

  • Onsen UI

    @kkng_88 In my last post I put a link to the docs and it’s updated there. I don’t know where did you find the wrong information. Are you perhaps checking v1 docs?