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

后端 未结 3 669
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 00:29

I\'m currently trying to build an Angular2 prototype (based on alpha44) of our Angular1 app (pretty complex one) and I\'m trying to find the best model/data architecture whe

相关标签:
3条回答
  • 2021-01-13 01:12

    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

    0 讨论(0)
  • 2021-01-13 01:13

    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.

    0 讨论(0)
  • 2021-01-13 01:22

    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)

    0 讨论(0)
提交回复
热议问题