angular-carousel
angular-carousel copied to clipboard
Problem when setting carouselIndex and ng-repeat array after some delay
Im using ng-repeat to render slides. The list of slides is retrieved from ajax request result. The same time Im setting carouselIndex. As a result I have carouselIndex is set to -1. This is because scope.$watchCollection(repeatCollection, function(newValue, oldValue) { occures later than scope.$parent.$watch(indexModel, function(newValue, oldValue) {
so as a result i have "newValue = slidesCount - 1" and this is "-1" because slidesCount is zero.
Expected behavior: carouselIndex should be exact the same that I set in my code.
+1 I'm also having a problem with this.
Here's what I'm doing:
- I have 7 items in the carousel, with the item at index 6 selected.
- I update the ng-repeat model with a list that has 37 items, which includes the original 6 items.
- I change the rn-carousel-index value to 30 (the new index of the item that was at index 6)
What happens is that the repeatCollection hasn't been updated yet, so when I set the rn-carousel-index value to 30 the indexModel gets set to 6 (length - 1). The carousel then displays the item at index 6, which is not the item I wanted to have displayed.