After creating a mobile application using the ionic framework with multiple images, I encountered an issue of flickering while loading them. To tackle this problem, I utilized $ImageCacheFactory
for preloading all images as described in a helpful blog post.
The code snippet used involved individually referring to each of the 100 png
images, which became quite cumbersome.
.run(function($ImageCacheFactory) {
$ImageCacheFactory.Cache([
"img/user.png",
"img/profile.png",
"img/logo.png",
"img/splash.png",
"img/map.png",
"img/shop.png",
"img/country.png",
"img/place.png"
]).then(function(){
console.log("Images done loading!");
},function(failed){
console.log("Error..!!!");
});
})
Is there a more efficient way to reference all the png images in one line of code, considering they are located in the www/img
folder? Thank you!