在ng-repeat循环中将json blob元素绑定到img src的其他方法?

问题描述

我有一个要在表中显示的json数组,如下所示:

<table><tr ng-repeat="field in databank.Fields">
  <td>{{field.name}}<br />{{field.description}}</td>
  <td><img src={{field.photo}} height=100/></td>
</tr></table>

数据库外观如下:

{"Fields":[{"description":"Field1 Description Text","index":1,"name":"Field One","photo":"data:image/png;base64,iVBOR..."},{"description":"Field2 Description Text","name":"Field Two",iVEa4..."}]}

这工作正常,但出现错误

获取https://localhost/%7B%7Bfield.photo%7D%7D 404(未找到)

在{{field.photo}}中被

解释,然后替换。

还有另一种绑定形式可以用来设置img src属性,该属性不会在ng-repeat替换之前从名为{{field.photo}}的文件中检索图像吗?

谢谢

解决方法

在这里找到了一个线索:AngularJS img ng-src binding doesn't work

这有效,没有错误:

<table><tr ng-repeat="field in databank.Fields">
  <td>{{field.name}}<br />{{field.description}}</td>
  <td><img ng-src={{field.photo}} height=100/></td>
</tr></table>