fix(router): wildcard routes with redirects
See original GitHub issueAs of alpha 36 there is no otherwise
route condition. The use case is where you want an invalid route or set of routes to either go to specific route or run a function that can do custom logic and re-route.
As another option for simple redirection, I would expect this to work, but it does not
@RouteConfig([
{ path: '/*', redirectTo: ROUTES.heroes }, //TODO: Need an otherwise in some way
{ path: ROUTES.about, as: 'about', component: AboutComponent },
{ path: ROUTES.heroes, as: 'heroes', component: HeroesComponent },
{ path: ROUTES.detail + '/:id', as: 'detail', component: HeroDetailComponent }
])
I’m requesting both an otherwise
and the * pattern above to work.
cc // @btford
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Wildcard route is not working every route is being redirected
In angular routing I have added this logic for invalid URL since then every route is being considered as invalid route
Read more >Default, Redirect and Wildcard Routes - AngularDart
As an alternative solution, remove the useAsDefault argument that you just added, and instead add a redirect route that will translate an initial...
Read more >Wildcard Routes (**) Can Redirect Relative To Their UrlTree ...
As a quick follow-up post, I wanted to demonstrate that a wildcard route can redirect to a URL that is relative to its...
Read more >Angular 9/8 How-To: Path Redirection and Handling 404 ...
Internally, the router uses a function called applyRedirects to process redirects. Step 5 - Handle 404 (not found pages) using wildcard paths.
Read more >next.config.js: Redirects
Redirects are not applied to client-side routing ( Link , router.push ), unless ... To match a wildcard path you can use *...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jakegraves
Sorry, from top of my head, don’t remember exactly. You can come to gitter to ask https://gitter.im/angular/angular you’ll find someone who knows
The router documentation and the cheat sheet IMHO should say something about @ericmartinezr solution