You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
route redirectTo not preserving query params #13315
[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Prior to release 2.3 query parameters were preserved through a configured route redirectTo. This is no longer working in 2.3. Is this an expected breaking change or was the prior behavior not correct?
Expected behavior
Query params preserved on a redirectTo, or at least allow it to be configured to do so.
Minimal reproduction of the problem with instructions
{ path: '',
redirectTo: '/component1',
pathMatch: 'full'
},
{ path: 'component1',
component: Component1
},
In Component1:
ngOnInit(): void {
let params = this.route.snapshot.queryParams; //route is ActivatedRoute
Prior to 2.3 params passed in url as /?param1=val1¶m2=val2 would be available to Component1
Please tell us about your environment:
Windows 7, VS Code
Angular version: 2.3
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Chrome, IE11
Result I get with this code running against 2.2.0 is:
Test Router Query Params
queryParams: params: {"param1":"val1","param2":"val2"}
routeData: params: {"param1":"val1","param2":"val2"}
I should add that I am not sure how to pass the query params into the plnnkr.
My bs-config.json has: "startPath": "/?param1=val1¶m2=val2"
@DzmitryShylovich what is the expected behavior for query params with redirects? I could not find any clear documentation. If what I was attempting is not really supposed to be supported I will change my code. Thanks.
I don't think this is ideal or logical. I don't see any reason why absolute paths shouldn't forward query params. At the very least, there should be a property to configure this.
Reacted by Patrick Geyer, Aryan J, C Moy and pmulac
The #1 reason to want to preserve those query params would be url re-writes where it is reasonable to assume the original url may be bookmarked by a user.
angular-automatic-lock-bot commented on Sep 14, 2019
Activity
DzmitryShylovich commentedon Dec 8, 2016
Pls add a repro in plunkr.
zoechi commentedon Dec 9, 2016
dup of #12664 ?
DzmitryShylovich commentedon Dec 9, 2016
don't think so. According to:
it's a regression.
mdsauer commentedon Dec 9, 2016
@DzmitryShylovich I would be happy to create a repro but I am not familiar with creating a repro in plnkr. I did see in another issue the following:
u can use http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5 as a starting point
But it is not clear to me how I specify the version of angular to run under. Can you point me to some instructions?
DzmitryShylovich commentedon Dec 9, 2016
u don't need to specify anything. the plunkr already uses the latest version.
mdsauer commentedon Dec 9, 2016
repro: http://plnkr.co/edit/EmmObNPt7lofzoM9YozT?p=preview
Result I get with this code running against 2.2.0 is:
Test Router Query Params
queryParams: params: {"param1":"val1","param2":"val2"}
routeData: params: {"param1":"val1","param2":"val2"}
I should add that I am not sure how to pass the query params into the plnnkr.
My bs-config.json has: "startPath": "/?param1=val1¶m2=val2"
@DzmitryShylovich what is the expected behavior for query params with redirects? I could not find any clear documentation. If what I was attempting is not really supposed to be supported I will change my code. Thanks.
mdsauer commentedon Dec 13, 2016
I changed my redirect from an absolute to a local and now the query params are retained. I think this issue can be closed.
DzmitryShylovich commentedon Dec 13, 2016
@mdsauer u can close it yourself
SusanAWAL commentedon Apr 11, 2018
@mdsauer can you put youe solution here, please?
veroca commentedon Oct 5, 2018
@SusanAWAL a little late I guess, but I'll leave the comment here for future visitors.
To conserve the query params, instead of:
do:
Ruluk commentedon Dec 28, 2018
I don't think this is ideal or logical. I don't see any reason why absolute paths shouldn't forward query params. At the very least, there should be a property to configure this.
MaverickH commentedon Jan 23, 2019
The #1 reason to want to preserve those query params would be url re-writes where it is reasonable to assume the original url may be bookmarked by a user.
angular-automatic-lock-bot commentedon Sep 14, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.