如何在Angular $ http中添加多个同名查询参数 [英] How to add multiple same-name query parameters in Angular $http
本文介绍了如何在Angular $ http中添加多个同名查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
全部
我想要做的是添加多个具有相同名称的参数来使用AngularJS $ http请求URL,使得URL被发送为 http:// localhost:8080 /?value = 1& value = 2 .....
What I want to do is Adding multiple parameters with same name to request URL with AngularJS $http, making the URL sent like http://localhost:8080/?value=1&value=2.....
这篇文章还描述了类似的情况:
使用多个具有相同名称的参数发送HTTP请求
This post also described the similar situation: Sending HTTP request with multiple parameters having same name
任何人都可以帮助AngularJS $ http?
Could any one help with in AngularJS $http?
谢谢
推荐答案
您需要使用如下数组:
var params = {};
params.someParmName = ['value1', 'value2'];
这将使用相同的查询字符串'someParmName'发送value1和value2。
This will send value1 and value2 with the same querystring key 'someParmName'.
以下是GET请求示例:
Here is an example GET request:
var parameters = {};
parameters.someParmName = ['value1', 'value2'];
$http({
url: 'api_url',
method: "GET",
params: parameters
});
这篇关于如何在Angular $ http中添加多个同名查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文