S
S
sanex33392016-02-12 18:01:05
JavaScript
sanex3339, 2016-02-12 18:01:05

Angular 2 - how to make a redirect along the route to the component with passing data to the component?

I receive some data data, for example, a complex object.
Next, I do a redirect on the route

let data = { ... }
this.router.navigate(['/edit-data']);

This redirect goes to the EditDataComponent component.
How can I pass this data to this component when redirecting?
Directly during the redirect, I found so far only through RouteParames, through GET parameters. https
://angular.io/docs/js/latest/api/router/Route...
I have complex data - it's bad to shove this object into GET parameters.
You can also pass data through RouteData, but such data is set during initialization of the component to which RouteConfig is attached.
What is the correct way to solve my problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
x512, 2016-02-12
@x512

this.router.navigate(['Home', { myVal: { x: 2, y: 3} }]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question