【发布时间】:2016-03-27 19:29:13
【问题描述】:
我的计划是使用 API(例如 Google Charts API)创建一个二维码,然后在我的网站上显示生成的二维码。我创建了一个从 Google Chart API 请求二维码图像的函数:
.controller('DealCtrl', function($scope, $http) {
$http.get("https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=160%20FSU728F29G&coe=UTF-8")
.success(function(data, status, headers, config) {
$scope.qrcode = data;
}).error(function(data, status, headers, config) {
$scope.qrcode = status;
});
})
当我尝试将响应绑定为 HTML 时,我得到了这个:
<div ng-bind-html="qrcode"></div>
响应似乎是一张图片 (PNG)。我怎样才能在我的网站上显示这个?
【问题讨论】:
-
我觉得还有更多内容,我不知道你为什么要发帖来获取图表。
-
不确定您对这条评论的意思。
-
你为什么发帖来获取二维码?
-
返回的图像是二进制数据 vs. Base64。 There is a similar SO question posted here with a possible solution
-
可能是个幼稚的问题,但网址是图片,为什么不按原样显示?
标签: javascript angularjs ajax google-api qr-code