Skip to content

Passing parameters without adding them to URL #8515

Closed

Description

@chickencoding123

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

Activity

  1. brandonroberts commented on May 6, 2016

    @brandonroberts
    Contributor

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

  2. chickencoding123 commented on May 6, 2016

    @chickencoding123
    Author

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

  3. alfakappa commented on May 24, 2016

    @alfakappa

    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?

  4. knight-bubble commented on Jun 28, 2016

    @knight-bubble

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

  5. sventorben commented on Aug 20, 2016

    @sventorben

    @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"?

  6. brandonroberts commented on Aug 20, 2016

    @brandonroberts
    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.

  7. sventorben commented on Aug 21, 2016

    @sventorben

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

  8. MTyson commented on Oct 3, 2016

    @MTyson

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

  9. shown24 commented on Dec 12, 2017

    @shown24

    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.

  10. abhiroopmn commented on Apr 9, 2018

    @abhiroopmn

    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.

  11. earshinov commented on Aug 6, 2018

    @earshinov

    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.

  12. andreaslarssen commented on Sep 5, 2018

    @andreaslarssen

    +1

  13. omer123456 commented on Oct 10, 2018

    @omer123456

    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');

  14. jasonaden commented on Dec 3, 2018

    @jasonaden
    Contributor

    See #27198 for an implementation that supports this.

  15. angular-automatic-lock-bot commented on Sep 14, 2019

    @angular-automatic-lock-bot

    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.

  16. locked and limited conversation to collaborators on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions