Preload image into a modal


#1

I have an $ionicModal which shows a random image each time.

The image itself can take some time to load. How would you suggest I preload the next random image as soon as the modal closes and before the user opens it again?

Here’s what I added to my modal code so far from the ionic example:

    $scope.openModal = function() {
        var random = Math.floor((Math.random() * 10) + 1);
        $scope.path = "img/ + random + ".jpg";
        $scope.modal.show();
    };

and in the modal html, I have this:

<ion-content>
    <img ng-src="{{path}}" width="100%" height="auto"/>
</ion-content>

Is this a straight js issue? Thanks for any suggestion!.


#2

Have you found any solution yet?