I have a basic angular resource (angular 1.0.7):
app.factory "User", [ "$resource", ($resource)->
$resource "/users/:id", { id: '@id' }, {
index: { method: 'GET', isArray: false }
}
]
I can pass parameters like:
User.index({ foo: 1, bar: 2 })
But I need to pass nested parameters:
User.index({ foo: { bar: 1 } })
And this fails because it sends:
/users?foo=%5Bobject+Object%5D
I tried:
User.index({ foo: JSON.stringify({ bar: 1 }) })
But obviously parameters are not recognised on the server side (mere strings) and I'd like to avoid the hassle of parsing there.
Do you have an elegant solution to this issue?
With jQuery I'd have done:
$.get("/users", { foo: { bar: 1 } } )
Producing:
/users?foo%5Bbar%5D=1
Perfectly interpreted by the server.
Seems like a known issue (here too), let's stick to an ugly patch from now...