AngularJs替换图像内容

时间:2016-01-18 12:43:32

标签: angularjs

我想要显示的图像取决于POST请求的响应。

<img ng-src="executePost()">

这是控制器。

$scope.executePost = function() {
    $http.post('/post', {'data':'reallylongstuffthatcantbedonewithget'}).then(function(result){
        console.log(result);
    }, function(data, status){});
}

响应(即console.log(result))是image / png类型。如何用POST请求返回的图像替换图像?我是否必须将图像发送回base64编码或是否有其他方式?

1 个答案:

答案 0 :(得分:0)

如果帖子返回成功,我想我会对图片网址执行操作。 base64解决方案似乎是实现目标的一种方式,但我认为帖子并不意味着要检索数据。