Aimery, before continuing, please help me understand what you are trying to do? If you are getting ONE thumbnail for your video, why are your using an ng-repeat at all?
Thanks, Mo On Friday, May 29, 2015 at 11:00:08 AM UTC-4, Aimery Marsily wrote: > > Thanks for clarifying the error, I understand now. > > When you are saying "*FIRST retrieve all your thumbnails > (getThumbnailUrl()) and store them in an array and THEN do an ng-repeat.*" > You mean that mon controller or link function should do that and not any > call in the template, is that it ? > > Le vendredi 29 mai 2015 16:15:23 UTC+2, Mo Moadeli (CREDACIOUS) a écrit : >> >> Basically you have a classic asynchronicity clash. Your main thread >> (ng-repeat) can't wait while each of your secondary threads ($http) takes >> their time so the ng-repeat loses it's place in the loop and continues >> indefinitely. It's somewhat like changing the 'i' within a for loop making >> it loop forever. >> >> In more detail, you are calling getThumbnailUrl() within your ng-repeat >> (main thread) which completes rapidly. Meanwhile, each getThumbnailUrl() >> is really an async $http call (separate thread) that WAITS for a 'success' >> callback/promise which takes FAR longer than the entire ng-repeat loop to >> complete. By the time ONE $http.success() returns the ng-repeat loop has >> lost where it is in it's index. And at that point ng-repeat is corrupt >> because it doesn't know what to show or where in the loop it is so it goes >> on and on. >> >> The solution is simple too. FIRST retrieve all your thumbnails >> (getThumbnailUrl()) and store them in an array and THEN do an ng-repeat. >> >> Hope this helps. >> >> >> >> On Friday, May 29, 2015 at 7:49:08 AM UTC-4, Aimery Marsily wrote: >>> >>> Hi all ! >>> >>> I have create a directive to get a thumbnail from a Vimeo video Url. But >>> when calling the Vimeo API with $http I end up with an infinite loop. You >>> can see it here : http://plnkr.co/edit/oqXxr4GdkaaThUxGNlnW?p=preview >>> WARNING : the problem is in the getThumbnailUrl() method that create an >>> infinite loop, you have to uncomment the code in it and paste in the input >>> a Vimeo video >>> >>> My directive should find the thumbnail of the video from the Vimeo API >>> and display it. I know I'm doing something wrong but can't find what. Any >>> help will be nice >>> >>> Nota : The Plunker code is a quick example, sorry if it's not clean >>> clean. >>> >> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
