Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Problem when setting carouselIndex and ng-repeat array after some delay #142

Open
alexgonchar opened this issue Apr 13, 2014 · 1 comment

Comments

@alexgonchar
Copy link

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.

@jshipley
Copy link

+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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants