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
Passing parameters without adding them to URL #8515
data is removed in rc1 release from Route. The remaining options currently are query strings and route parameters. Both of which visibly add values to URLs. There are many scenarios for which the user doesn't need to see passed values as part of URL, and that makes URLs user friendly while the functionality remains the same. Currently to pass an arbitrary value from one component to another without appending it to URL, a data service or a mediator is required. Either of two are an added complexity if the arbitrary value is a simple token of some sort.
I suggest bringing back the data as well as adding an optional Boolean value to router.navigate which specifies if passed values are supposed to be added to URL. If false then pass them behind the scene and if true do as what happens currently (query string or route param).
Reacted by Norbert Korny, Kamil Dąbrowski, Ali Salehi, mcgri, Suguru Inatomi, Sean McGill, Tobias Gassmann, user414, knight-bubble, Daneil Pan and 14 more
@hirtie-maxim,
I stumbled across this issue, because I was looking for a way to dynamically pass data from one component to another via routing. I had a look at #9619, but could not figure out how this may help.
Especially it is unclear to me how to pass data without showing up in the URL. Is it possible at all?
Adding "data" to the routing configuration seems to be very static, so that does not solve the issue. Did I overlook something with the "resolves"?
@sventorben if you want to pass data between routes without it showing up in the URL, you should use a service instead of route data. Route data is static with the exception of resolves that get merged into route data after completion.
Reacted by Günter Zöchbauer, knight-bubble and Sagar Jadhav
@brandonroberts Thanks for clarification. Though, I was hoping for a different answer. ;)
To parahrize an analogy: This feels as if someone took the HTTP protocol and stripped POST, PUT and DELETE and left me with GET only.
I am just wondering why there is no such thing as a "default resolve" which is implicitly available on every route. This would allow to pass some data when triggering navigation. That data could get automatically merged into route data after completion.
Reacted by Matt Tyson, fghgfhgryry5464yhrtyrtyt, Fidel, Yusong Yue, Sai, Guillermo, tsabak, Luis Paredes, Oleg Zheleznov, Todd Nichols and 6 more
What is the use of static data? I can do this in the constructor or when the component is initialized. I think that this feature should be added to "router.navigate" as a parameter. I do not understand how it has not been realized so far. For example, you can bind the state of a form to navigation. If I go back, how do I return the state of the form? I do not want to store all the form's params in the URL. How can "Share Service" help here? A snapshot of the router with my data would be very convenient.
Did anyone figure out a way to pass data while navigating (not passing params in URL)? I definitely seem to need this in one of my cases.
Reacted by wfe8006, Samantha Combs, MariusVlas, lipsarout, Marco Lackovic, Aravinth loganathan, Matthew Marlin, seyidaniels, lucifer63, Petyo Cholakov and 2 more
this is a walk around , far from being perfect but it dose work..
this.router.navigate(['./', 'signup'],{ queryParams: { page: 1 }, skipLocationChange: true });
window.history.pushState('','','register');
Activity
brandonroberts commentedon May 6, 2016
The router will have some feature parity with the deprecated router, so route data will be brought back.
chickencoding123 commentedon May 6, 2016
So far no news about adding
datato new router nor any suggestions about how to go about this issue.alfakappa commentedon May 24, 2016
When will it be brought back? I need it in my application. Working with deprecated-stuff is a bit weird to do in an "up to date" app.
edit: I also do not want to pass this data in my url as an object, since this give other/new troubles (and I do not want a user to see all this stuff)
@brandonroberts any news on this?
knight-bubble commentedon Jun 28, 2016
@hanijizan, I think this PR #9619 fix it.
sventorben commentedon Aug 20, 2016
@hirtie-maxim,
I stumbled across this issue, because I was looking for a way to dynamically pass data from one component to another via routing. I had a look at #9619, but could not figure out how this may help.
Especially it is unclear to me how to pass data without showing up in the URL. Is it possible at all?
Adding "data" to the routing configuration seems to be very static, so that does not solve the issue. Did I overlook something with the "resolves"?
brandonroberts commentedon Aug 20, 2016
@sventorben if you want to pass data between routes without it showing up in the URL, you should use a service instead of route data. Route data is static with the exception of resolves that get merged into route data after completion.
sventorben commentedon Aug 21, 2016
@brandonroberts Thanks for clarification. Though, I was hoping for a different answer. ;)
To parahrize an analogy: This feels as if someone took the HTTP protocol and stripped POST, PUT and DELETE and left me with GET only.
I am just wondering why there is no such thing as a "default resolve" which is implicitly available on every route. This would allow to pass some data when triggering navigation. That data could get automatically merged into route data after completion.
MTyson commentedon Oct 3, 2016
It does feel pretty cumbersome to create a shared service just to pass an object into a route...
shown24 commentedon Dec 12, 2017
What is the use of static data? I can do this in the constructor or when the component is initialized. I think that this feature should be added to "router.navigate" as a parameter. I do not understand how it has not been realized so far. For example, you can bind the state of a form to navigation. If I go back, how do I return the state of the form? I do not want to store all the form's params in the URL. How can "Share Service" help here? A snapshot of the router with my data would be very convenient.
abhiroopmn commentedon Apr 9, 2018
Did anyone figure out a way to pass data while navigating (not passing params in URL)? I definitely seem to need this in one of my cases.
earshinov commentedon Aug 6, 2018
List of tickets about passing data with router.navigate:
Currently all the tickets are closed (except #10248 which addressed only a part of the problem), and the issue is still here.
andreaslarssen commentedon Sep 5, 2018
+1
omer123456 commentedon Oct 10, 2018
this is a walk around , far from being perfect but it dose work..
this.router.navigate(['./', 'signup'],{ queryParams: { page: 1 }, skipLocationChange: true });
window.history.pushState('','','register');
jasonaden commentedon Dec 3, 2018
See #27198 for an implementation that supports this.
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.