【发布时间】:2013-07-05 02:42:58
【问题描述】:
如何从 AngularJS 中的 JSON HTTP 响应解析 $?
试图在没有 JQuery 的情况下抓取 YouTube 搜索结果:
$http.get('http://gdata.youtube.com/feeds/api/videos/-/chocolate?alt=json&orderby=published')
.success(function (data) {
$scope.video_list = data;
})
.error(function (data) {
$scope.video_list = data;
});
那个没有错误响应,安慰它的时候得到一个Object;但不能在里面查询。
$scope.video_list_fun = function () {
$http.get('http://gdata.youtube.com/feeds/api/videos/-/chocolate?alt=json&orderby=published').then(function (response) {
$scope.video_list = response.data;
});
};
这里也一样,也尝试过使用, 链接else。
$scope.video_list = (httpGet('http://gdata.youtube.com/feeds/api/videos/-/chocolate?alt=json&orderby=published'
)); // HttpGet from http://stackoverflow.com/a/4033310/587021
这可行,但是当我解析它时,例如:JSON.parse; AngularJS 去掉了所有带有$ 的键。
请注意,我曾尝试使用 their other API,但无法获得相同的结果(并且无法包含它们对发布日期和质量有用的参数;因为它已损坏)。
【问题讨论】:
-
查看this github issue,似乎没有什么好的解决方案...
标签: javascript json angularjs youtube-api angularjs-service