0

I'm trying to call a image from array of object, for this purpose I have written below code

product: any[] = [{
    id: 121, name: "iphone", url: 'https://www.gstatic.com/webp/gallery3/1.png'
}] //I tried locale file path also

And calling this image like below

<div *ngFor="let list of product">
    {{list.url}}
</div>

but it is not showing image rather than it showing only string. Could any one please let me know how to call a image which is defined in array

3 Answers 3

3

You need to use img tag to render image into view part within your iteration.

Try this -

<div *ngFor="let list of product">
    <img [src]='list.url' />
</div>

Working example

Sign up to request clarification or add additional context in comments.

Comments

2

Put URL in <img> tag with source binding:

<div *ngFor="let list of product">
    <img [src]='list.url' [alt]='list.name'/>
</div>

Comments

0

you can try this solution

<div *ngFor="let list of product">
    <img [src]='list.url'/>
</div

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.