Preload image into a modal

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";

and in the modal html, I have this:

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

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

1 Like

Have you found any solution yet?