Looked over some relevant posts:
Why am I getting a 404 error with ng-src even though image is appearing?
AngularJS ng-src path to image
Understanding AngularJS ng-src
Conditionally change img src based on model data
but none have the exact same symptoms.
This line of code,
<img ng-src="{{movie.Poster}}" alt="">
where movie
is JSON and movie.Poster
is a string of a url, seems to be the root of this error:
GET http://ia.media-imdb.com/images/M/MV5BMTk3OTIzODUyOV5BMl5BanBnXkFtZTYwNjgxNjA5._V1_SX300.jpg 403 (Forbidden)
Because the image url is good and complete in the error, the url string property movie.Poster
seems to have been passed to ng-src ok/in time. However, many of the seemingly relevant posts emphasize that asynchronicity of JS may be responsible (and in this case movie.Poster
does depend on a response from an API).
But if the url is in the error, why does ng-src have a problem requesting the image and displaying anything at all? An above post closest to my issue was able to load the image AND give the console error...
Perhaps the oddest thing is if I navigate to the image url (by copying and pasting that url) into another tab on the browser, then return to my app and click back then forward, the image loads without error!
I tried ng-if="movie.Poster"
and...
$scope anotherVar = movie.Poster
in the controller and then ng-src="{{anotherVar}}"