Closed imperez closed 4 years ago
Yeah, that's absolutely a great idea.
The loose plan in my head is to replace the default params argument in .to
with it's own .defaults
method, which assigns default values to routes and resources alike. Will probably release that in an upcoming point release.
In the meantime, you can achieve a similar effect by doing something like this:
// capture a reference to the resource
var rs = router.resource('Posts')
// then access the member and collection routes directly to override their options:
// same endpoint new defaults
rs.member_route.to( 'Posts.show', { lang: 'en' } )
// same endpoint new defaults
rs.collection_route.to( 'Posts.index', { something: 'else' } )
Not great, but should at least un-stick you for now!
Your workaround works great for me! It'll due until this feature is released.
Thanks!
I noticed .to() can take a second paramter extra_params. It would be good if this was also available for .resource that would eventually get passed to their sub .to() calls.