How do I share data between components in Angular 2?

后端 未结 6 493
故里飘歌
故里飘歌 2020-11-22 05:04

In Angular 1.x.x you simply ask for the same service and you end up with the same instance, making it possible to share the data in the service.

Now in Angular 2 I h

6条回答
  •  孤街浪徒
    2020-11-22 05:56

    In parent Component template:

    
    
    

    In child Component:

    @Input() hero: Hero;
    

    Source: https://angular.io/docs/ts/latest/cookbook/component-communication.html

提交回复
热议问题