How to inject data into Angular2 component created from a router?

人盡茶涼 提交于 2019-12-01 05:15:15
Yaniv Efraim

You can use RouteData in order to pass data into routes. See here and here. I'm still missing the part of initialising this data obj from the component (see my question regarding)

Günter Zöchbauer

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

data support also was added to the new router in RC.4. For details see How do I pass data in Angular 2 components while using Routing?

Angular 2 - equivalent to router resolve data for new router might also be related.

Toan

You can pass (inject) data from child component inside Router Outlet to Parent component with Subject,Observable. You can found my solution in this video.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!