function preloadImages(array) {
if (!preloadImages.list) {
preloadImages.list = [];
}
for (var i = 0; i < array.length; i++) {
var img = new Image();
img.src = array[i];
preloadImages.list.push(img);
}
}
var imageURLs = [
"url1.jpg",
"url2.jpg",
"url3.jpg"
];
preloadImages(imageURLs);
--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
Hello!
A generic solution is to use the application cache, which is designed for just this purpose: https://developer.mozilla.org/en-US/docs/HTML/Using_the_application_cache
Josh
(Sent from my mobile)
It works in all modern browsers plus IE10: http://caniuse.com/#feat=offline-apps. But yeah, not the best if you need legacy browser support. But unlike the other methods, this will work across page refreshes. There are trade-offs.
Josh
(Sent from my mobile)
"Unfortunately, IE doesn't have..." is the beginning to so many sentences. :-)
$templateCache takes a string, but you can easily leverage it with $http:
$http.get( templatePath, { cache: $templateCache }).then(function (response) {
// you probably don't need to do anything with the promise
// but you could:
var template = response.data;
});
The caches used by $http are the same as the $templateCache, so if you pass the $templateCache to your $http request, the response will be cached as a template. Done. :-)
Josh
(Sent from my mobile)
Thanks for the answers. I will definity look into application cache and also the manual approach wich saving images.$templateCache itself does only support strings? Would be nice if it would take an external html template file as an argument like the router does. So it could load the file from the server and save its content with the specific key.
--
Thanks for the answers. I will definity look into application cache and also the manual approach wich saving images.$templateCache itself does only support strings? Would be nice if it would take an external html template file as an argument like the router does. So it could load the file from the server and save its content with the specific key.
--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.