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
Optional Routing Parameters issue #32853
Comments
please can it be prioritized? |
Similar issue - #3957 (comment) But was closed without fixing. High priority issues and needs fix. |
++1 |
Have either of you tried to use matcher option? For cases at work, usually simple redirect with trailing slash was good enough. For few other cases custom matcher was the solution, it's a bit verbose but not too complicated. Just make sure that you export the function! (Needed for AOT) EDIT: here is an example to use as a matcher option
Just an FYI, you'll need to cast this function to UrlMatcher because of #29824 |
@FDIM Thanks for response
But I not able to understand how to use URLmatcher. how and where to write URLmatcher code so it can prevent route breaking and consider as blank param ? Clicking on routerLink element its working as expected, but on refresh it's considering till |
@ajarudingunga In regards to double slash, I'd try matcher approach first and see if it just works before replacing built on methods. |
@FDIM I have tried below code, but same issue for double slash. if I pass some value of optional param then its working.
|
Any other solutions? Can we prioritize this? |
I was able to reproduce this with 8.2.13. Seems like a bug in the parsing or init code because if there is any value provided in between |
I created a workaround for this issue using a custom The issue seems to be due to a bug in the url parsing logic at: angular/packages/router/src/url_tree.ts Line 477 in 8b91ea5
This code assumes that |
@IgorMinar Given stackblitz seems working for angulr 8. code written in app.modules.ts I have tried with angular 5.2.11 but not working with lazyload children routes, throwing error like module not found.
|
@IgorMinar Found scenarios where code working/not working. If I run with |
Anyhow, we managed in the frontend by editing prod dist files by removing |
The workaround is working for A8 and SSR Universal App. |
🐞 bug report
Affected Package
@angular/router
Is this a regression?
Yes, working in angularjs 1.x
Description
Optional Routing Parameters issue
Route declaration
const routes: Routes = [
{ path: '', component: SearchpagesComponent ,
children: [
{
path: ’near/:nearSearch/:val1/:val2/:name/:filter', loadChildren: './near-search/near-search.module#NearSearchModule',
}
]
}
];
RouterLink config
<a [routerLink]="['/near/','','37’,’122','San-Francisco','All']" > Goto Near Page - San Francisco
by this we are able to achieve optional param and able to load component and URL generated by routerLink is below which is expected
http://localhost:3000/near//37/122/San-Francisco/All
but when we refresh or reload page it's not working and redirecting to http://localhost:3000/
-Two forward slash after near "//" is required and url should remain same.
-Expected fix is if we pass
nearSearch
params as a null component should be loaded and and blank forward slash '//' should be persist in URL'🔥 Exception or Error
Redirecting back to home page
🌍 Your Environment
Angular Version:
Angular 5
The text was updated successfully, but these errors were encountered: