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

Suggested improvement for rnCarouselIndicators #417

Open
KevIvers opened this issue Sep 21, 2016 · 1 comment
Open

Suggested improvement for rnCarouselIndicators #417

KevIvers opened this issue Sep 21, 2016 · 1 comment

Comments

@KevIvers
Copy link

Hi,

The rnCarouselIndicators wasn't working for me because of a scoping context issue. In the line indexModel.assign(scope.$parent.$parent, index); .$parent.$parent has the wrong context, for the particular scope item I am specifying in the reCarouselIndex attribute. It's an unsafe assumption really, to say where that value will be scoped, in terms of parent hierarchy.

Since that param, is already a two way locally scoped item (signaled by '=' local scope declaration), am I missing something else, as to why you don't just assign the updated index straight into the local scoped index.

The following fixes my issue
//var indexModel = $parse(iAttributes.rnCarouselIndex);
scope.goToSlide = function (index) {
//indexModel.assign(scope.$parent.$parent, index);
scope.index = index;
};
Regards,
Kev

@KevIvers
Copy link
Author

Just to add to this, I tracked my problem down, to the requirement of the inclusion of the ng-if="slides.length > 1" in the original defining element. I wasn't using it, as I had static amount of items in the carousel, so didn't see the need for it. The inclusion of ng-if creates its own scope context, which means the the original scope.$parent.$parent will work.

Maybe the docs should be updated to signify ng-if is a requirement for indicator to work.

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

1 participant