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
chickencoding123 opened this issue May 6, 2016 · 15 comments
Closed

Passing parameters without adding them to URL #8515

chickencoding123 opened this issue May 6, 2016 · 15 comments

Comments

@chickencoding123
Copy link

chickencoding123 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
Copy link
Contributor

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

@chickencoding123
Copy link
Author

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

@alfakappa
Copy link

alfakappa 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
Copy link

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

@sventorben
Copy link

@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
Copy link
Contributor

@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
Copy link

@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
Copy link

MTyson commented Oct 3, 2016

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

@shown24
Copy link

shown24 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
Copy link

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
Copy link

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
Copy link

+1

@omer123456
Copy link

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
Copy link
Contributor

See #27198 for an implementation that supports this.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests