Skip to content
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

Passing parameters without adding them to URL #8515

Closed
IRoninCoder opened this issue May 6, 2016 · 14 comments

Comments

Projects
None yet
@IRoninCoder
Copy link

commented May 6, 2016

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).

@brandonroberts

This comment has been minimized.

Copy link
Contributor

commented May 6, 2016

The router will have some feature parity with the deprecated router, so route data will be brought back.

@IRoninCoder

This comment has been minimized.

Copy link
Author

commented May 6, 2016

So far no news about adding data to new router nor any suggestions about how to go about this issue.

@alfakappa

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link

commented Jun 28, 2016

@hanijizan, I think this PR #9619 fix it.

@sventorben

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link
Contributor

commented 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

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link

commented Oct 3, 2016

It does feel pretty cumbersome to create a shared service just to pass an object into a route...

@shown24

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link

commented Sep 5, 2018

+1

@omer123456

This comment has been minimized.

Copy link

commented 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

This comment has been minimized.

Copy link
Contributor

commented Dec 3, 2018

See #27198 for an implementation that supports this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.