小编Los*_*eey的帖子

如何在Angular JS中显示作为字节数组接收的图像

我有一个服务器端应用程序将返回一个图像.这些是响应标头:

Content-Disposition: attachment; filename=8822a009-944e-43f4-999b-d297198d302a;1.0_low-res
Content-Length: 502343
Content-Type: image/png
Date: Mon, 03 Aug 2015 19:13:39 GMT
Server: Apache-Coyote/1.1
Run Code Online (Sandbox Code Playgroud)

在角度,我需要显示图像.在获取图像时,我使用angularJS $http来调用服务器并将结果放在范围内,但我从未达到成功函数$http.从邮递员执行此调用会正常返回图像.我很想知道如何让Angular显示图像.

这是我显示图像的方式:

<img ng-src={{image}} />
Run Code Online (Sandbox Code Playgroud)

这是从服务器获取图像的调用:

$http.get(url, {responseType: "arraybuffer"})
    .success(function(data) {
        $scope.image= data;
    }
)
Run Code Online (Sandbox Code Playgroud)

javascript image bytearray httpresponse angularjs

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

angularjs ×1

bytearray ×1

httpresponse ×1

image ×1

javascript ×1