Stanley Xuan Luo Stanley Xuan Luo - 1 year ago 48
AngularJS Question

Unwanted GET request in ng-repeat

I'm making a simple Angular Flickr Photo Feeder:
Codepen link

After searching for some tag, there is a list of returned

items displayed by ng-repeat. And at the very beginning, there should be no item in the list, thus there should be no

However when starting the app, in the console it shows a 404 error (can't get
,which is the
attribute of
element). This means there is at least one
element in the beginning.

Any thoughts, and how to prevent this error?

Answer Source

Use ng-src insetad of src. That way you won't get an error.

<img class="img-responsive" ng-src="{{}}">

From the official AngularJS documentation:

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.