- Search queries
- Sort: client-side, no refiring of model hook
- Sort: server-side, refire model hook
- Pagination + Sorting
- Boolean values. False value removes QP from URL
- Global query params on app route
- Opt-in to full transition via refresh()
- replaceUrl by changing controller QP property
- w/ {{partial}} helper for easy tabbing
- link-to with no route name, only QP change
- Complex: serializing textarea content into URL (and subexpressions))
- Arrays
Last active
April 21, 2023 17:14
-
-
Save machty/8167051 to your computer and use it in GitHub Desktop.
Ember Query Param API examples
Just came up with a way to use object based query params which seems to work:
In the controller you need to map the controller property to your query param key:
queryParams: ['sort',{
entityNameFilterValue: 'filter[entity.entity-name]'
}],
Then in the routers model function you need to construct the params however you want based on the controller value:
model: function(params){
if(params.entityNameFilterValue){
params.filter = {};
params.filter['entity.entity-name'] = params.entityNameFilterValue;
delete params.entityNameFilterValue;
}
// do your store lookup now with params
}
Thanks for this!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1 on how to use objects in the query params (e.g.,
/book/5?filter[chapter]=Chapter1
). This style is used heavily in json api and should be supported by Ember. Any ideas on how to go about it? It's also recommended for paging/books?page[number]=1&page[size]=100