3

I have a table with many rows and each row has a preview image to be shown on the top right corner when mouse is hovering the row.

This is how I put the image tag with AngularJS binding for URL in src attribute:

<img src="{{imageUrl}}"/>

But there is the following error in console:

GET http://localhost/#/imageUrl 404 (Not Found)

How to get rid of this error in browser console?

1
  • 1
    Use ng-src instead of src Commented Jan 6, 2017 at 9:53

2 Answers 2

19

Angular has its own directive for img, called ng-src:

<img ng-src="{{imageUrl}}"/>
Sign up to request clarification or add additional context in comments.

Comments

3

You need to use ng-src instead of src in your <img> tag.

The documentation says like this,

Using Angular markup like {{hash}} in a src attribute doesn't work right: The browser will fetch from the URL with the literal text {{hash}} until Angular replaces the expression inside {{hash}}. The ngSrc directive solves this problem.

https://docs.angularjs.org/api/ng/directive/ngSrc

Hope this helps!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.