$http 获取参数不起作用 [英] $http get parameters does not work
本文介绍了$http 获取参数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道为什么这不起作用吗?
Does anyone know why this does not work?
$http
.get('accept.php', {
source: link,
category_id: category
})
.success(function (data, status) {
$scope.info_show = data
});
这确实有效:
$http
.get('accept.php?source=' + link + '&category_id=' + category)
.success(function (data, status) {
$scope.info_show = data
});
推荐答案
get
调用中的第二个参数是一个配置对象.你想要这样的东西:
The 2nd parameter in the get
call is a config object. You want something like this:
$http
.get('accept.php', {
params: {
source: link,
category_id: category
}
})
.success(function (data,status) {
$scope.info_show = data
});
请参阅http://docs.angularjs 的参数部分.org/api/ng.$http 了解更多详情
See the Arguments section of http://docs.angularjs.org/api/ng.$http for more detail
这篇关于$http 获取参数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文