angular-carousel
angular-carousel copied to clipboard
Using rn-carousel-controls causes TypeError: Cannot read property 'length' of undefined when using controllerAs syntax in parent
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
Confirm, we have the same problem with 0.3.13 version, 0.3.12 was fine
@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.
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
+1 looking forward to the fix :)
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
@gregorholzmann It worked for me thanks!
+1 i would think rn-carousel-control should not be required to address this bug. Will update after fix.
@gregorholzmann It worked for me too, thanks!
+1
rn-carousel-control does not display arrow controls to me
+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...
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 Look for another one, you can read this in the Readme:
This project is not maintained anymore, and looking for maintainers.
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
Is not working on my end even with 1.0.1 @vsapozhnik =(
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!