sharataka
sharataka

Reputation: 5132

How to prefetch an image in AngularJS?

I am trying to prefetch an image in my Angular app that sits within a Chrome plugin.

In the controller, I have:

$scope.nextlocation = 'http://i.imgur.com/Vzidbt4.gif';

In my view, I have:

<link rel="prefetch" href="{{nextlocation}}">

When I load the page, I get an error saying:

GET chrome-extension://jlkgcdcdoooiaeamkhagpdolhgjgfgem/%7B%7Bnextlocation%7D%7D net::ERR_FILE_NOT_FOUND

When I hardcord the image in the doc, like below, it works fine.

<link rel="prefetch" href="http://i.imgur.com/Vzidbt4.gif">

How do I get this to work so that it dynamically updates?

Upvotes: 0

Views: 168

Answers (1)

Thalaivar
Thalaivar

Reputation: 23622

<link rel="prefetch" href="http://i.imgur.com/Vzidbt4.gif">

Change the above to:

<link rel="prefetch" ng-href="{{nextlocation}}">

Upvotes: 2

Related Questions