[BUG]: provideFileRouter not working

This issue has been tracked since 2023-01-11.

Please provide the environment you discovered this bug in.

Local development, reproduction here: https://github.com/markmals/analog-router-bug-reproduction

Which area/package is the issue in?

router

Description

The router doesn't display the index route's template (<h2>) nested in the root route via the <router-outlet> and throws an error when you try to navigate to /docs/:name (e.g. /docs/foo)

Please provide the exception or error you saw

ERROR Error: Uncaught (in promise): Error: NG04002: Cannot match any routes. URL Segment: 'docs/foo'
Error: NG04002: Cannot match any routes. URL Segment: 'docs/foo'

Other information

Also tested with docs.[name].ts (as opposed to docs/[name].ts), neither works

I would be willing to submit a PR to fix this issue

  • Yes
  • No
brandonroberts wrote this answer on 2023-01-18

This is a docs issue, but you have a couple of options here.

Create a route file named docs.[name].ts which is equivalent to docs/:name with no nesting.

Create a parent/child route

  • docs.ts // <-- parent route with a router-outlet
  • docs
    • [name].ts // route

Which will make docs/[name] but nested

markmals wrote this answer on 2023-01-18

It's still not rendering the index route and I also tested it with docs.[name].ts, which gave me the same error. I updated the reproduction to reflect this: https://github.com/markmals/analog-router-bug-reproduction

brandonroberts wrote this answer on 2023-01-18

Your repo is using an older version of @analogjs/router https://github.com/markmals/analog-router-bug-reproduction/blob/main/package.json#L10

If I update it to latest 0.1.0-alpha.4 it works correctly

markmals wrote this answer on 2023-01-18

Awesome, I've verified that is working on my end as well. Thanks for the help

More Details About Repo
Owner Name analogjs
Repo Name analog
Full Name analogjs/analog
Language TypeScript
Created Date 2022-07-06
Updated Date 2023-03-28
Star Count 885
Watcher Count 18
Fork Count 67
Issue Count 33

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date