-
Notifications
You must be signed in to change notification settings - Fork 25.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router: Using UrlMatcher function throws error that path is not defined #12972
Comments
@bontscho Please add a plunker that reproduces your problem. The team has no capacity to reproduce each and every issue on their own based on instructions. |
i added the plnkr, hope this helps |
How |
here you have the corresponding error code when you use both at the same time: matcher is your custom function to define the path your route should match, here you can have optional parameters just like described in my use case |
@bontscho i have replicated your code into demo project... I am unable to hit the component even though i pass url starting with "sample-url". Can you please let me know if i am missing something. Below is my code for routing export const APP_ROUTES: Routes = [ export function matcherFunction(url: UrlSegment[]) { |
@ronaksharma8 the ** route should be the last, since it will always return a match (404). your last route with the matcherFunction therefore will never be checked by the router. try putting the matcher function route before the ** route |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
When using the matcher function in Routes, it throws an error that no path has been defined.
Sample Config according to source code:
The issue is in these 3 error messages:
https://github.com/angular/angular/blob/master/modules/@angular/router/src/config.ts#L409
These error messages should be corrected to consider an existing matcher function. When omitting these 3 errors, it works as intended.
Expected behavior
It should execute the matcher function and route to the correct component for the given url
Minimal reproduction of the problem with instructions
Just add the provided
matcher
function and omit thepath
property for any given routeplnkr: http://plnkr.co/edit/vtpDnJQ4YGtuRAryknqo?p=preview
What is the motivation / use case for changing the behavior?
My usecase is to have a matcher for a route with an optional id so the routes:
/news-articles
and
/news-articles/:id
are one route so the component does not get initialised again when navigating from /news-articles to /news-articles/:id
Please tell us about your environment:
Mac OS Sierra 10.12.1, VScode 1.7.1
Angular version: 2.2.2
Router version 3.2.2
Browser: all
Language: Typescript
Node (for AoT issues):
node --version
= 6.9.1The text was updated successfully, but these errors were encountered: