Reinstantiating ion-slides (Ionic 1.2.4)


Hi guys,

I’m building a calendar component using ion-slides. I need to load years dynamically as i swipe through the calendar. For that i use an array and ng-repeat for displaying ion-slide-pages . I start by creating the current year and as i swipe through the calendar i’ll create the prev/next years.
So, when I’m on index 0, i’ll prepend 12 months to de calendar and append 12 months when index = array.length-1.
The problem is that when the array is updated (when prepending entries), the swiper activeIndex is still 0, so i’ll jump from Jan 2016 to Jan 2015, which is now the item at index 0.

Here’s my code:

Using $timeout, i’m able to “slideTo” the right position, but it’s not a great solution and you’ll notice a glitch (uncomment line 32 to see the behaviour).

I was wondering if i could re-instantiate the swiper with different options, after the array is updated, maybe i could use “initialSlide” to start on the desired index, but i don’t know how can i achieve this, or if this will also cause a glitch.

Can anyone help me with this? Any other ideas?
I’m also new to angularjs, and maybe there’s a simple way to solve this. Any help would be appreciated

Thanks in advance