chrisben / imgcache.js

JS library based on the File API to cache images for offline recovery (target: cordova/phonegap & chrome)
Other
826 stars 216 forks source link

Question Carrousel Images #184

Closed kamzam777 closed 7 years ago

kamzam777 commented 7 years ago

I'm trying to use imgcache.js in an AngularJS/Cordova app, I tested ImgCache.useCachedFileWithSource() with a single image component and its working excellent but I can't make it works with images inside a Carrousel.

Initially I populate the images with URLS in a $scope array I can cache each URL but I can't replace the URL with the Cache File into the Carrousel.

For a single image, I use the following code to get the image element var elementAngular = document.getElementById('banner'); var element = angular.element(elementAngular); ImgCache.useCachedFileWithSource(element, $scope.src);

For the Carrousel, I tried: var elementAngular = document.getElementById('banner'); var element = angular.element(elementAngular); ImgCache.useCachedFileWithSource(element[0], $scope.src); To replace the position [0] in the Carrousel.

How I should code to replace each position in the Carrousel? I tried to retrieve the Cache file path but it returns me the URL again, if I got the storage path I can replace the URLS value with the storage path in the $scope array to display the image?

Thanks for your support,

chrisben commented 7 years ago

I'm afraid I won't be able to help much there. This issue is specific to your code, it doesn't look like a problem with imgcache itself. I advise you to enable logging (ImgCache.options.debug = true) to see what happens and what gets downloaded/cached or not. It looks like your problem is with using Angular itself.

kamzam777 commented 7 years ago

Thanks for your response, I avoid using ng-repeat and create one element per image and it works great.