$scope.getQuery = function() {
var response = $http.post('/test/getQuery', $scope.query, $scope.algoName);
response.success(function(data, status, headers, config) {
console.log($scope.query);
console.log($scope.algoName);
});
}
这里我传递了$scope.query
, $scope.algoName
。这在 AngularJS 中可能吗?
最佳答案
您可以将它们作为 data
传入参数$http.post()
接受:
var data = {
query: $scope.query,
algoName: $scope.algoName
};
$scope.getQuery = function() {
var response = $http.post('/test/getQuery', data);
response.success(function(data, status, headers, config) {
console.log($scope.query);
console.log($scope.algoName);
});
};
这些将作为请求消息数据发送。
关于javascript - 可以在 Angular JS 的 HTTP post 请求中传递多个 $scope 变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31699175/