javascript - Angular2 : How to display image to HTML from JSON API -




i new ionic , developing e-commerce mobile app. using json api, can data api except image, cannot display image coming json api. have no idea how can display image html. hope can me, thank in advance. here how json api looks like:

product: [         {         prod_id: 1,         supplier_id: 8,         prod_name: "hippo + friends baby boy triangle merino pant",         prod_price: "250",         prod_stock: "20",         prod_image: "assets/img/4ef1ef51ef6e2f0142452af60048df44merino pants.jpg"     }     ] 

.html file

<img [src]="getimageuri(product.prod_image)"      alt="image preview..."> 

.ts file

getimageuri(image: string): string {   if (!image) {     image = `/assets/img/noimage.jpg`;   }    const uri = `${environment.assets}/${image}`;   return uri; } 

environment.assets host location of image.

example environment.assets = http://hostlocation.com/images;

i'm assuming since e-commerce site aren't bundling images app handled through kind of cms.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -