gpt4 book ai didi

javascript - 可以在 Angular JS 的 HTTP post 请求中传递多个 $scope 变量吗?

转载 作者:行者123 更新时间:2023-11-30 08:35:29 26 4
gpt4 key购买 nike

  $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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com