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

Errors with Angular 1.3

Open samaxes opened this issue 9 years ago • 10 comments

When a ngIf directive resolves to false on a rn-carousel element, angular-carousel crashes with the following error in loop:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: cspSafeGetter; newVal: -1; oldVal: 0"],["fn: cspSafeGetter; newVal: 0; oldVal: -1"],["fn: cspSafeGetter; newVal: -1; oldVal: 0"],["fn: cspSafeGetter; newVal: 0; oldVal: -1"],["fn: cspSafeGetter; newVal: -1; oldVal: 0"]]
http://errors.angularjs.org/1.3.2/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3A…5B%22fn%3A%20cspSafeGetter%3B%20newVal%3A%20-1%3B%20oldVal%3A%200%22%5D%5D
    at http://localhost:9000/bower_components/angular/angular.js:80:12
    at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:14080:19)
    at Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:14304:24)
    at done (http://localhost:9000/bower_components/angular/angular.js:9518:47)
    at completeRequest (http://localhost:9000/bower_components/angular/angular.js:9703:7)
    at XMLHttpRequest.requestLoaded (http://localhost:9000/bower_components/angular/angular.js:9646:9) 

On line 537 of the dist file (var oldSlides = (currentSlides || newValue).slice();) we also need to check for undefined values:

TypeError: Cannot read property 'slice' of undefined
    at http://localhost:9000/bower_components/angular-carousel/dist/angular-carousel.js:537:76
    at Object.$watchCollectionAction [as fn] (http://localhost:9000/bower_components/angular/angular.js:13907:13)
    at Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:14042:29)
    at Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:14304:24)
    at done (http://localhost:9000/bower_components/angular/angular.js:9518:47)
    at completeRequest (http://localhost:9000/bower_components/angular/angular.js:9703:7)
    at XMLHttpRequest.requestLoaded (http://localhost:9000/bower_components/angular/angular.js:9646:9) 

samaxes avatar Nov 08 '14 01:11 samaxes

I am also getting the second error on my local machine. Unfortunately, I can't reproduce it on Plunker: http://plnkr.co/edit/x5MDsmHRcG9V1hDUkGeL?p=preview

Is there any quick fix for this?

ComFreek avatar Nov 08 '14 14:11 ComFreek

Unfortunately the first error happens with Angular 1.2 as well.

Please visit this Plunker to see it in action: http://plnkr.co/edit/kKD4kOuomBiPjky3ofED?p=preview

If you comment the directive test-slide and use the li element directly, the error goes away.

samaxes avatar Nov 24 '14 19:11 samaxes

Hi @revolunet, have you had the time to look at this issue?

samaxes avatar Jan 07 '15 19:01 samaxes

Ran into same issue today - Angular 1.3.x

albertpak avatar Jan 17 '15 06:01 albertpak

I have the second error as well. My version number is 1.2.28.

judezhu avatar Jan 24 '15 21:01 judezhu

Me too I have the same error, it's appear when we load in asynchrous the data like ajax call. When I populate directly the slides with $scope.slides = {slide1, slide2 ...} I have no issue.

matohawk avatar Jan 27 '15 01:01 matohawk

I have the same error. As matohawk said, i load the data asynchronous.

ghost avatar Jan 28 '15 14:01 ghost

We are using a#1.3.11. We had similar problem whenever the carousel were empty (including async data loading). We have added ng-if="dataSetNotEmpty" above the rn-carousel and this solves the issue.

equus71 avatar Feb 17 '15 07:02 equus71

thanks. @equus71 it works!

saystone avatar Mar 23 '15 03:03 saystone

Thanks @equus71. It works, the error is gone.

tonyawad88 avatar Jun 20 '15 12:06 tonyawad88