angular-carousel icon indicating copy to clipboard operation
angular-carousel copied to clipboard

Suggested improvement for rnCarouselIndicators

Open KevIvers opened this issue 7 years ago • 1 comments

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 avatar Sep 21 '16 09:09 KevIvers

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.

KevIvers avatar Sep 21 '16 13:09 KevIvers