Jaromjj Jaromjj - 1 year ago 95
AngularJS Question

Angular use ng-src in an image tag within ng-repeat

I have used ng-src on img tags many times within ng-repeats with success, but for some reason I can't get this one to work.

I have an API call that returns some data, and for each item in the return, I basically do this:

<div ng-repeat="item in APIreturn">
<img ng-src="{{item.url}}" />

I have also tried
and so forth. I've verified that the url that is being used is valid, and works fine in
outside of the ng-repeat.

Any ideas why it would be different in the ng-repeat?

Current HTML

<table ng-repeat="user in userInformation">
<td><img ng-src"user.image" /></td>

These are both using the same element in this object...but for some reason the image render

Answer Source

You say you don't see the url if you put just <td>{{ user.image }}</td>. This indicate you access not existing property on yout object. Try json filter:

<td>{{ user | json }}</td>

to see more of your object. As I can see, you use capital letters, but user.image is lower cased.

EDIT: here is a working plunkr.

EDIT2: you missing assign sign.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download