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

Using rn-carousel-controls causes TypeError: Cannot read property 'length' of undefined when using controllerAs syntax in parent

Open anishbenji opened this issue 8 years ago • 15 comments

This is a new bug introduced in 0.3.13 causing TypeError: Cannot read property 'length' of undefined. If you use the controllerAs syntax in the parent, when you instantiate the directive with rn-carousel-controls, you get the above error in the following piece of code: scope[repeatCollection.replace('::', '')].length

I've copied the first example from the angular-carousel demo page & recreated the error in the following plunker. http://plnkr.co/edit/dE1V4A?p=preview

anishbenji avatar Aug 31 '15 07:08 anishbenji

Confirm, we have the same problem with 0.3.13 version, 0.3.12 was fine

PeterKow avatar Sep 14 '15 11:09 PeterKow

@anishbenji I was able to get around this by using rn-carousel-control instead of rn-carousel-controls.

Looks like this fixed the issue in the example, also.

gregorholzmann avatar Sep 23 '15 17:09 gregorholzmann

Use simple variables in repeat collection to avoid this problem, because scope[repeatCollection.replace('::', '')] doesn't work properly

bad - dm.slides

<ul rn-carousel rn-carousel-controls rn-carousel-index="dm.carouselIndex">
          <li ng-repeat="slide in dm.slides">{{ slide.id }}</li>
        </ul>

good - slides

<ul rn-carousel rn-carousel-controls rn-carousel-index="dm.carouselIndex">
          <li ng-repeat="slide in slides">{{ slide.id }}</li>
        </ul>

I hope that author will fix it in a next version

idutka avatar Sep 24 '15 17:09 idutka

+1 looking forward to the fix :)

mackelito avatar Oct 01 '15 17:10 mackelito

If you use multi level object when that code processes the replace will get you something like "one.two" as string and then is trying to read it like $scope['one.two'] which is not the same than $scope.one.two

sonicd300 avatar Nov 13 '15 00:11 sonicd300

@gregorholzmann It worked for me thanks!

cristiancedenogallego avatar Jan 15 '16 20:01 cristiancedenogallego

+1 i would think rn-carousel-control should not be required to address this bug. Will update after fix.

priley86 avatar Jan 25 '16 15:01 priley86

@gregorholzmann It worked for me too, thanks!

daniel-nalbach avatar Feb 05 '16 16:02 daniel-nalbach

+1

rn-carousel-control does not display arrow controls to me

ghost avatar Apr 15 '16 15:04 ghost

+1 like @theupmachine said, using rn-carousel-control isn't a solution to this error... It's not displaying anything... Using 'simple' variables also not a solution...

camielm avatar Apr 18 '16 12:04 camielm

Non of the solutions provided work. Is there any PR open to fix this or should we try with another library for the time being?

cyntss avatar Jul 05 '16 14:07 cyntss

@cyntss Look for another one, you can read this in the Readme:

This project is not maintained anymore, and looking for maintainers.

Rulox avatar Jul 05 '16 15:07 Rulox

Download version 1.0.1 which fixed this issue. Somehow the person that fixed the issue forgot to update bower.json with new version, but package.json states that current version (which was changed few months ago) is 1.0.1

vsapozhnik avatar Jul 08 '16 15:07 vsapozhnik

Is not working on my end even with 1.0.1 @vsapozhnik =(

Rulox avatar Jul 08 '16 16:07 Rulox

I have the same problem with a collection that isn't set on first render. I solved using ng-if on rn-carousel

<ul rn-carousel rn-carousel-controls ng-if="vm.business.products">
  <li ng-repeat="singleProduct in vm.business.products">
    ...
  </li>
</ul>

Hope it helps!

coire1 avatar Aug 10 '16 13:08 coire1