问题
Using Ember 1.8.0 and Ember Data 1.0.0-beta.11, Ember store's findQuery() function doesn't seem able to handle dynamic segments, or at least I'm not able to find it in documentation anywhere.
For example, given the following routes
MyApp.Router.map ->
@resource 'users', ->
@resource 'user'
path: 'users/:user_id'
, ->
I know that
store.findQuery('user', {foo: 'bar'})
sends a GET request to
myapp.com/users?foo=bar
and also,
store.find('user', 1)
sends a GET request to
myapp.com/users/1
but now I want to send a GET request to
myapp.com/users/1?foo=bar
and I can't figure out how to do this or if it's even possible. Hopefully I'm just missing something really obvious. Any advice would be appreciated!
回答1:
This PR will enable this scenario by introducing queryOne method, but is not yet merged into Ember.Data master.
Until then you could override findQuery method on ApplicationAdapter, such that id param would be passed as part of url and other params as query params. See JsBin for example.
来源:https://stackoverflow.com/questions/27121840/ember-data-dynamic-segments-and-query-params-together