我正在尝试从响应对象获取图像URL并将其存储在变量中,这是从服务器获取图像URL的代码
$http.post("http://aflaree.com/apmsservice/securityService.svc/AvailableFacility",loginID)
.success(function(response){
console.log(response);
console.log(response.facility);
console.log(response.FacilityImage);
$scope.img = response.FacilityImage;
console.log($scope.img);
})
.error(function(response){
console.log(response);
});
这是我计划显示图像的HTML
<div >
<img ng-src="{{img}}">
</div>
问题
我可以存储或查看响应中除FacilityImage字段以外的任何字段的日志。
一些如何如果我能够将图像存储到$ scope.img中,那么使用两种方式的数据绑定将能够在html页面中显示我的图像
如果还有其他方法可以访问FacilityImage形式的图像网址,请让我知道如何在我的视图中显示该图像。
FacilityImage是设施的属性,因此您必须像这样访问它:
response.facility.FacilityImage
希望这可以帮助!
更新:实际上事件会更深一层,因为设施是具有多个设施的阵列,因此假设您选择第一个设施:
response.facility[0].FacilityImage
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句