【发布时间】:2019-11-03 03:45:21
【问题描述】:
我无法从我的第一个 http get 请求访问输出变量,我需要此数据用于另一个 http Post 请求。
无。
$scope.submit = function(x) {
$http({
method: "GET",
url: url + 'getOSchild',
params: { ncard: x }
}).then(function success(response) {
$scope.osChild = response.data;
console.log($scope.osChild) // this has an output
}, function error(response, status) {
console.log(response)
console.log(status)
});
$http({
method: "POST",
url: url + 'printOS',
data: JSON.stringify({
CARD_NAME: data_cname,
C_DATE: data_date,
C_NUMATCARD: data_ncard,
C_DISTMEANS: data_means,
C_TIME: data_time,
cData: $scope.osChild //this is null
}),
header: {
'Content-Type': 'application/json'
},
}).then(function success(response) {
console.log(response)
}, function error(response, status) {});
}
我需要 $scope.osChild 出现在我的 http post 请求中。
【问题讨论】:
标签: angularjs angular-promise angularjs-http