我已经看到以下SO问题通过GET请求使用AngularJS'$ http服务发送数组和从Angular $ http POST传递数据数组.但那里建议的解决方案似乎对我不起作用.我特别关注数组对象.
我有以下AngularJS ajax调用数组参数
return $http({
method: 'GET',
url: '/api/PatientCategoryApi/PatCat',
params: { "numbers[]": [{ First: 999, Second: 888 }]},
headers: { 'Content-Type': 'application/Json' }
})
Run Code Online (Sandbox Code Playgroud)
该调用生成的url似乎对我不起作用.我尝试了各种params的化身,并且生成的url(通过使用fiddler得到它们)如下.
params: { numbers: JSON.stringify([{ First: 999, Second: 888 }]) },
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers=%5B%7B%22First%22:999,%22Second%22:888%7D%5D
params: { "numbers[]": JSON.stringify([{ First: 999, Second: 888 }]) },
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%5B%7B%22First%22:999,%22Second%22:888%7D%5D
params: { "numbers[]": [{ First: 999, Second: 888 }]},
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%7B%22First%22:999,%22Second%22:888%7D
params: { numbers: [{ First: 999, Second: 888 }]},
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%7B%22First%22:999,%22Second%22:888%7D
Run Code Online (Sandbox Code Playgroud)
我希望网址为http:// localhost:50849/api/PatientCategoryApi/PatCat?numbers …