In my Angular 2 application I have a list of users "Users:any" which contain the properties: name, job, age... etc. The problem is that to get the profile image I have to get the the id of the image from the Users object, then use a web service getImage(ImageId)
, so I have this in my html:
<div *ngfor="let user of users">
<img [src]="getImage(user.profileImageId)"/>
In this case, I can't get the profile image displayed, I think the html is loading before the data?
Just try this, this worked for me.
TS:
getImage(id){
return http.get(url/id);
}
HTML:
<img [src]="getImage(user.profileImageId)" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With