Ember data - dynamic segments and query params together?

佐手、 提交于 2019-12-12 09:02:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!