Reputation: 127
Server response to me document(in Json) with information. And in this json i have a url to image. And every time when i load new content of page( with new image) it appear but in console have error:
I use url from json in angular to display image on my website.
More info from fiddler:
Screen in chrome loaded image:
Help me to solve this problem.
Upvotes: 2
Views: 2520
Reputation: 492
You need to use ng-src to prevent the browser from fetching the image before the {{content.imageURL}} resolved by Angular.
More information from ng-src docs: http://docs.angularjs.org/api/ng.directive:ngSrc
Upvotes: 1
Reputation: 42669
Instead of src
attribute Set ng-src
in your html markup whereever you are binding the url to json response. Something like
<img ng-src="{{content.imageUrl}}"/>
Using src
causes browser to make a request before binding is resolved.
More details here
Upvotes: 4