Angular 4 Route fails if added parameter with hyphen
See original GitHub issueI am using Angular 4 and if I use hyphen between parameters instead of slash, the route does not work as expected. Here is my route:
{ path: ':bookId/:pageFrom-:pageTo', component: BookComponent }
I was expecting to receive the values of pageFrom
and pageTo
in separate params but I am receiving it in pageFrom-:pageTo
. I have also tried to escape the hyphen with \
but that also does not work.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Angular path with hyphen character not allowed - Stack Overflow
The path is not changed but it works when I use following: $location.path('/product/ninja_game');. Is there anything specific to hyphen/dash ...
Read more >A Single Route Parameter Can Match Multiple URL Segments ...
Ben Nadel demonstrates that route parameters can match multiple URL segments in Angular 4.4.4. This allows us to capture entire URL suffixes ...
Read more >Common Routing Tasks - Angular
This topic describes how to implement many of the common tasks associated with adding the Angular router to your application.
Read more >Razor Pages route and app conventions in ASP.NET Core
To specify a page route, add route segments, or add parameters to a route, use the page's @page directive. For more information, see...
Read more >Overview - Reach Router
Reach Router is a small, simple router for React that borrows from React Router, Ember, ... Router manages the focus of your app...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
I have other ideas also to implement it like splitting the string later by hyphen… But I am looking for something more genuine like this
{ path: ':bookId/:pageFrom-:pageTo', component: BookComponent }
which will allow the use of hyphen-
as separator instead of/
This is also useful for my visitors to use shortest/simple possible link instead of providing custom query parameters.
Use following code this.
In your component do