How to enter data into an Angular2 component created using a router

I'm currently trying to prototype Angular2 (based on alpha44) of our Angular1 application (rather complicated), and I'm trying to find a better model / data architecture using routes and child routes.

In my example, from a child component created using a route, I want to access the property of the parent component (by hosting a router-outlet ).

But when you create a component from router-outlet , you can no longer use @Input and @Output . So what is the best practice for entering some data / properties besides the base routeParams and static routeData ?

How do you communicate with the parent component without over-communication?

+6
angular components router
source share
3 answers

You can use RouteData to transfer data to routes. See here and here . I am still missing the initialization part of this obj data from the component (see my question )

+2
source share

The shared service can be used with components added by the router. See https://angular.io/docs/ts/latest/cookbook/component-communication.html for details

data support has also been added to the new router in RC.4. For more details, see How to transfer data in Angular 2 components when using routing?

Angular 2 - The equivalent router permission data for a new router can also be connected.

+2
source share

You can transfer (enter) data from the child component inside the Outlet router to the parent component with Subject, Observable. You can find my solution in this video .

See the code on GitHub: https://github.com/tabvn/angular-blog

0
source share

All Articles