【发布时间】:2014-09-01 15:24:37
【问题描述】:
我在 json 响应形式的 restful api 中获取图像,我必须使用 angularjs 在 html 中使用该图像。
我不知道如何使用 angularJs 使用该图像
如果我尝试这样 "http:/api/image/id",其中 id 是 "userID"。但是当我在 angularjs 中编写代码时,我没有得到任何响应。我尝试使用断点调试代码,但它没有进入函数内部
JS 代码
QAApp.controller('imgCtrl', function ($scope, $http) {
$scope.image = function (id) {
var request = $http({
method: 'GET',
url: server + 'api/image/' + id,
});
request.success(function(data, status, headers, config) {
console.log(data);
});
}
});
HTML 代码
<div class="artst-pic pull-left" ng-controller="imgCtrl">
<img ng-show = "{{image(q.userID)}}" alt="" class="img-responsive" />K
</div>
请告诉我如何使用它。
【问题讨论】:
-
如果你能发布你的 JSON 的样子会有所帮助。
-
我无法发布 json 响应,通过使用此 url localhost:8000/api/image/id,然后它将直接显示图像而不是 url,所以我必须显示该图像...我没有得到任何解决方案我如何使用它............哪里 /api/image/id 这是 api 路径......
-
对象 {数据:“����JFIFHH���ExifMM*...������f�*�c#���B���z������h� ��)Ob��5��o�QY��", status: 200, headers: function, config: Object}..... 我收到这样的 json 响应
标签: angularjs