Using src working just fine, unlike what the tutorial says

What is the difference between src

and ng-src

? I read from the documentation that:

This directive prevents the browser from processing Angular markup {{expression}} literally

But when I tested it with help <img src="{{phone.url}}">

it worked fine. I am using the latest angularJs.

And what is the reason? is the tutorial outdated or am I missing something?

+3


source to share


1 answer


Yes, it will work with the attribute src

. But by the time angular has loaded and processed the HTML, an HTTP GET request with a split url will already be sent:

http://yourdomain.com/%7B%7Bphone.url%7D%7D

      



which will obviously be 404. To prevent this from happening, you must use a directive ngSrc

that sets the correct src

one as soon as all the required variables are removed. The browser then starts downloading the actual image resource.

+5


source







All Articles