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
Router navigate with Route Data #5217
Comments
Not supported. What exactly would you expect to happen? |
I need to navigate to a component and send data to it dynamically. |
@btford can you help? |
looking to do the same - any help here? other options? Basic problem is parent gets data from an API and needs to send data to child after subscription. |
Is there a reason why a Service would not be useful in this case? |
@matteosuppo Also, what if I refresh the page? The service would lost its state. |
Is there a reason you want to navigate by url why not use the navigate method like this: in RouteConf: in /path: |
NG 1 allowed us to "get" the state object and attach data to it, so we could then pull it off the $state.data object. . In all the examples I have seen, the data on NG2 routes looks to be static. How do I attach data in a routeData param dynamically? |
@mbcooper Currently, you don't |
Is this issue on anyone's radar? |
store it in yours service, you don't need to make a new API call |
@mahpah I was under the impression that a new instance of my service is being created every time the router navigates from one route to another. |
related to the old router |
Feel like this was closed very prematurely. I think there's plenty of valid use cases for it |
It would be great to not have to add another field to a service when all I want to do is know the state of one variable, once, from the previous view, without making the url longer |
I'd like to use this for a static page title when re-using existing components. Adding a service feels a little bit over powered. |
Yeah, I feel like this is a pretty common use case. I don't need to resolve the data, I already have it. I just want to pass it along to the route I'm navigating to. Sure, we can make a service with the sole purpose of being a temporary state holder / transfer-er, but it just feels gross and unnecessary. Yes, paramMap exists, but it tries to serialize everything to the url (which I also don't need in this case), so it can't support complex/nested objects. |
You can use this. Angular2+/4/5 - navigate with data https://github.com/Hipparch/Angular2-navigate-with-data |
@Hipparch , With all due respect, this feels more like a hack. For a problem that is so common one would expect a supported and well-tested solution built into Angular. |
@vicb, Sure it relates to the old router, but it relates to the current router just as well. Please reopen this ticket. Otherwise another ticket should be opened for the current router. |
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. |
+1 |
you guys can use https://www.npmjs.com/package/ngx-navigation-with-data |
|
See #27198 for an implementation that supports this. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Is it possible to navigate to an URL and give a json object to it?
As:
Best regards,
Tiago Braga
The text was updated successfully, but these errors were encountered: