[英]JSON Object Access from Response
[
{
"productName": "saree",
"productDescription": "bomkai saree",
"productDiscountPrice": 12000,
"imageUrl": "drdrfd",
"productActualPrice": 12400,
"productImages": [
{
"id": 10,
"name": "Screenshot from 2022-09-05 18-27-38.png",
"type": "image/png",
"picByte": "3B0JoYZ1QGDSDBwyYAP0p4AgqrkuCDxrnc4dx3KCk4kHrj3rRbY3EgluN4exFo2KYC4pdyHuuog3KfVIPlDWvoS1uGO8T1nVByTumaZbzz/PYNA7DacA8zbANn4tGqDy2IQ563ZKYGxgkdA1DdNNjFlwzn6k+OO4Hjj27mAqXhcbyvg+SVoaYpDOGcyemBNINSGCd4UOLuvN5fjzXW08cNM95EULIhse4yDHWaFt+Rts6HHWXWgPrusOJ+YfGTI3/A4U7lzwWAyjoAAAAAElFTkSuQmCC"
}
],
"id": 22
}
]
how i can Access picByte from angular UI,我如何从 angular UI 访问 picByte,
i got response from the api with list of obect inside other object like i mentioned here,the productImages is a seperate list i need productImages.picByte value to set inside image tag to make a view,how can i do it?我得到了 api 的响应,其中包含其他 object 中的对象列表,就像我在这里提到的那样,productImages 是一个单独的列表,我需要 productImages.picByte 值来设置内部图像标签以进行查看,我该怎么做? with a for loop or any thing?
用for循环或任何东西? please help( https://i.stack.imgur.com/x0a6e.png )]( https://i.stack.imgur.com/Ib8vA.png ),i need to shoe these byte inside my image tag for display the images,
请帮助( https://i.stack.imgur.com/x0a6e.png )]( https://i.stack.imgur.com/Ib8vA.png ),我需要将这些字节放入我的图像标签中以供显示图像,
You should be able to easily just loop through the results in your html as so:您应该能够轻松地遍历 html 中的结果,如下所示:
<div *ngFor="let data of myObject">
<p>Id: {{data.id}}</p>
<img
*ngFor="let images of data.productImages"
[src]="getImageSrc(images.picByte)"
width="250px"
height="250px"
/>
</div>
Where myObject
is your apiResponse. myObject
是您的 apiResponse。 getImageSrc
is defined in the component code as: getImageSrc
在组件代码中定义为:
getImageSrc(image: string) {
return 'data:image/png;base64, ' + image;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.