-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$resource Arrays as parameters support needed #2256
Comments
Hello guys, I've made some modifications to angularjs-resource.js. I'm not too sure about how to contribute, but I compiled the unified diff here, it's pretty straight forward, and it supports the times when query strings are "arrays" (made the check at typeof), just like the use-case I have mentioned above.
This will now send the following request: Please kindly comment and advise. Perhaps if it were helpful at all, this fix can come up in the next release. Thank you very much for your kind attention! Cheers, |
Fixed a bug. Here's the global change.
|
Hello I was wondering if this issue is being looked at. I thought it might be convenient for this to get fixed together on the next revision, so I don't have to make the merge everything AngularJS gets a new version. Can someone please kindly clarify on this? Thank you very much for your attention. |
The fix does not do it for me. For some reason, when I use request to send parameters the execution of code does not go inside if (!self.urlParams[key]) {...} -section. I don't use object with key-value -pairs but but array of strings. My resource: angular.module('someService', ['ngResource']).
factory('Article', function($resource) {
return $resource('api/articles/:keywords', {keywords: '@keywords'}, {
query: {method:'GET', params:{}, isArray:true}
});
}); Usage: var update = Article.query({keywords: $scope.keywords}, function() {
$scope.articles = update;
}); |
Hello Matti, Thanks for your comment. Chees, |
In my case Angular produces api/articles/param1,param2,param3. Now that you say this I have to admit I have no idea what the RESTful URL would look like in this case.. |
Hello, |
+1 |
In ver 1.1.5 the issue was solved. |
Looks like this has since been resolved. |
Hello guys,
I have problems trying to use the $resource library in AngularJS to send a properly serialized GET request when there is an array of checkboxes (client_status) in my GET parameters.
This is the code I have right now in my controller:
$scope.filters = {
client_status: ["CLIENT_STATUS_FORMER", "CLIENT_STATUS_ACTIVE"],
client_reference: "e"
}
$scope.records = Client.get($scope.filters, function(data){
...
}
The above will send the following GET request:
f.json?client_reference=e&client_status=CLIENT_STATUS_FORMER,CLIENT_STATUS_ACTIVE
However, from what I understand, the above seems like it's not the correct format (at least for my REST server). The following is what I expect:
f.json?client_reference=e&client_status%5B%5D=CLIENT_STATUS_ACTIVE&client_status%5B%5D=CLIENT_STATUS_FORMER
May I ask for a fix on this? Or perhaps, if there are different standards for different servers, can this mode be supported somehow?
The use case here would be checkbox groups, multi-selects etc.
Your help is greatly appreciated!
Cheers,
Thomas
PS - Together with this task, I've also made a directive that can bind checkbox inputs more conveniently (as a array of values). I'd like to share & contribute this, and perhaps have someone look and refactor my code if necessary, but who should I talk to on this?
The text was updated successfully, but these errors were encountered: