How to route to sibling route

I would like to route to a sibling route in Aurelia v2, but I can’t get it to work. Could someone help me, please?

Thanks for any advice.

Hi @elitastic! Thanks for trying out router-lite. Here is one working example: Routing to route from parent component not working (forked) - StackBlitz

There are a couple of issues.

  • The dependencies were too outdated. When working with SB, delete the package-lock, use the dev tag for all the aurelia dependencies, save the project and reload. This creates a new lock file, which you can later also save to the project.
  • The load and href attribute always looks for the route under current routing context. As the product route isn’t found under the products component, it wasn’t working. There are 2 ways this can be solved. You can use a ../prefix for the route (example: <a load="../product/xy"> Link to product/xy </a>), when you are using a string path. Or you can bind the context property when you are preferring the non-string routing instructions, which can be viewed to be a bit more structured. However, as your routes are all defined on the root component, it suffices to bind a null to the context; for example: <a load="route: product; params.bind: { productId: '12' }; context.bind: null" >Link to product/12 </a>.

P.S. The docs for the router-lite is on the way.

1 Like

Thank you very much for your detailed answer!