Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$resource Arrays as parameters support needed #2256

Closed
@bs-thomas

Description

@bs-thomas

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions