css - 从位于 JSON 中的 url 获取图像

标签 css angular image typescript

我需要提取 url 并将其显示为图片:

从 json 看如何:

how it looks from json

我的 html:

<ul>
  <li *ngFor="let product of store.Products">

    <p>Product ProductImage: {{ product.ProductImage }}</p>
    <p>Product Price: {{ product.Price }}</p>

  </li>
</ul>

我可以用管道做吗?

最佳答案

我在你提供的json中看到一个空格,你需要

<p>Product ProductImage: {{ product["Product ProductImage"] }}</p>
<p>Product Price: {{ product.Price }}</p>

如果要看图片需要替换成图片标签

  <p><img [src]="product["Product ProductImage"]" /></p>
  <p>Product Price: {{ product.Price }}</p>

关于css - 从位于 JSON 中的 url 获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52889302/

相关文章:

html - CSS 3 子菜单在悬停时不可见

javascript - Angular2 在输入中显示两位小数

c# - 在 ASP.NET 中动态生成 PNG 的好方法是什么?

jQuery css() 在 if 语句中不起作用

javascript - Angular2嵌套组件: Error: core_2.输入不是函数加载http ://localhost:9080/app/boot. js时出错

html - 用不同的图片翻转图像网格

javascript - jQuery .change() 函数问题

javascript - 更改滚动上的 div 不透明度

html - div定位,奇怪的行为

css - 将数据传递给样式组件 angular2