analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

[BUG]: provideFileRouter not working #208

Closed markmals closed 1 year ago

markmals commented 1 year ago

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

brandonroberts commented 1 year ago

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

Which will make docs/[name] but nested

markmals commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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