gpt4 book ai didi

javascript - Angular $http.query 使用数组作为参数?

转载 作者:行者123 更新时间:2023-12-01 03:00:35 25 4
gpt4 key购买 nike

我有一个 Angular 1 应用程序,用户可以通过单击复选框来选择多个项目。当他单击特定按钮时,这些 Id 会聚合如下:

angular.forEach($scope.orders, function (order, id) {
if (order.export) {
ids.push(order.id);
}
});

现在我想在我的 php api 操作中查询这些 Id,但是如何将所有 id 传输到我的 apiAction?我用 $http.query ($scope.items = Items.query({ 'ids' : ids});) 尝试过,但这不起作用创建一个无法解析的奇怪网址。

然后我尝试使用:$http.save,在那里我可以将 id 传输到我的 api 操作,但我还需要将结果返回到我的应用程序以便将其显示在前端,但使用 $http.save 这似乎不可能,因为我总是收到 orderBy:notarray 错误。

那么我如何使用 $http.save 并获得一个正确的数组作为返回,或者使用 $http.query 以及参数中包含多个 id 的数组?

谢谢

最佳答案

在 Angular $http 调用中...

params: {
id: JSON.stringify(ids)
}

关于javascript - Angular $http.query 使用数组作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46450172/

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