Aurelia Direct Router: Error on router.load(...)


when calling router.load("...") this results in the following error:

The “dummy-page” is imported in the html.

Also <a load="dummy-page"> results in error when placed in “welcome-page”. It only works in the app.html where the au-viewport is placed.

I’ve registered the direct router in the main.ts:

Any idea what I’m missing?

First of all, in order to be using the direct router you need to import IRouter from aurelia-direct-router, not from aurelia.

Second, when calling .load() don’t add the path: part, just the component(s) you want to load.

Finally, when using relative routing, as in not starting the route with a /, the routing/viewport context of where the router starts looking for a viewport is the routing context of where the link is. If you want to load a component in the same viewport as the component with the link using a relative route, you’ll need first step up one routing/viewport context: ../dummy-page. (Or use an absolute route to start in the root routing/viewport context: /dummy-page.)

Hi jwx,

thanks for your help! I really appreciate it.

The information to import from aurelia instead of aurelia-direct-router I got from the help page (Navigating With Load - aurelia-direct-router). Maybe this is no longer up to date?

Also the use of path is written in this help page. However, I am not sure anymore what exactly is the meaning behind it. Can you give me a small example of when to work with “path”?