-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$http config.param expands array values properly. #1364
Conversation
Today, calling e.g. $http(url, { params: { a: [1,2,3] } }) results in a query string like "?a=%5B1%2C2%2C3%5D" which is undesirable. This commit enhances buildURL to createa query string like "?a=1&a=2&a=3".
Very nice pull request! Can you please sign our CLA and I'll merge it in. CLA is important for us to be able to avoid legal troubles down the road. For individuals (a simple click-through form): For corporations (print, sign and scan+email, fax or mail): |
Thanks! I signed the CLA a couple days ago; am I waiting for some kind of |
hey can we make this a configurable hook? with jquery for example, the default is to do arrays like &foo[]=1&foo[]=2 and you pass a traditional: true flag in if you want &foo=1&foo=2 ... since I have some back end targets setup for the brackets it'd be nice if we could expose the whole buildUrl method to configuration. |
My concern is that this dies on the vine while people discuss the relative As it stands, this patch does not prohibit you from passing { "foo[]": |
OK, I'm fine with that. Can I also note though that ngResource also suffers from this as it doesn't seem to use $http to build its URLs. Perhaps that is best mentioned on that file... |
Oh, that stinks. I imagine I'll work on a patch for that soon, then. |
tweaked the commit message a bit and landed this as 79af2ba thanks for the contribution. if you don't have our t-shirt yet please fill out this form: http://goo.gl/075Sj |
Awesome, glad to see this go in! Looking forward to my tshirt ;) |
Nice fix guy! I'm experiencing the same issue with $ressource is there the same bug? |
I've removed the 'use strict' and it works like a charm. Sorry for the noise! |
does this also fix the $resource object? seems this is still a problem: https://groups.google.com/forum/#!msg/angular/mAqaKXGm3Fg/fOazZvB8GBcJ |
No. At least, not when it was merged.
|
@tdavis does that mean its still broken or is it fixed in a later version? |
Likely still broken. Unless $resource has been refactored to use the same
|
@tdavis would you suggest using the bleeding edge of angular.js? I feel like its hard to use stable with all the build processes of angular.js and making sure the bug hasn't been patched in newer versions. Also, if you end up finding a bug in unstable, just submit a patch right? :) |
👍 |
Today, calling e.g. $http(url, { params: { a: [1,2,3] } }) results in a query
string like "?a=%5B1%2C2%2C3%5D" which is undesirable. This commit enhances
buildURL to createa query string like "?a=1&a=2&a=3".
Fixes #1363.