Hi @elitastic! Sorry for the delayed reply. I would primarily point you to the relevant docs for this: https://docs.aurelia.io/router-lite/navigating. The docs should sufficiently cover this topic.
Now to answer your individual questions…
- Is it possible to navigate by queryParams in
load
custom attribute?
No. The load attribute does not support binding query parameters. Please refer to the docs, for the supported properties of the load
CA.
- In general, how is the route id differentiated from the routing path?
From the docs:
The unique ID for this route. The router-lite implicitly generates a id
for a given route, if an explicit value for this property is missing. … this can be used to generate the href
s in the view when using the load
custom attribute or using the Router#load
API. Using this property is also very convenient when there are multiple aliases for a single route, and we need a unique way to refer to this route.
Is xy
a route id or a route path? Could it be both?
Yes, it could be both. Sometimes, the lookup using the route-ids is often prioritized internally over recognizing a path. However, as the route
property is polymorphic, you are free to choose among route-id, path, or a route view-model class.
- Shouldn’t it be possible to route by params in
router.load()
(like it is in the load custom attribute)?
It is already possible. Instead of,
this.router.load('product', { params: { id: 'product-1' } }
you need to do this
this.router.load({ component: 'product', params: {id: 'product-1' } })
Check out this working example: router-lite - IRouter#load - string-instructions - StackBlitz.
- Is it possible to route to a route id combined with passing a route context?
Yes, it is possible. Refer to the docs: https://docs.aurelia.io/router-lite/navigating#customize-the-routing-context. However, it works only if the route-id is used. Thus, the following from your example won’t work.
<a load="route: ../product; params.bind: { id: 'product-1' }">Navigate</a>
The assumption is that if you are binding a path, then you can also add the parameters. Using a path and the parameters at the same time can be semantically confusing, IMO. In your example, you have done something like below.
this.router.load('product-path', {
queryParams: { id: 'product-1' },
context: this.routeContext.parent,
});
This is also incorrect, as you are trying to add the route (path) parameters to the query.