How do I share data between sibling components in angular?

前端 未结 4 1313
轮回少年
轮回少年 2021-02-04 08:08

I have an Angular application with 3 sibling components, they are able to access and update the variable \"data\". They are connected to the router, but the data I want to pass

4条回答
  •  情深已故
    2021-02-04 08:59

    Since you have multiple receiver components, Best way is to use a singleton shared service. Because later if you create more receiver components, emitting to each and every individual component would not be appropriate.

    Incase you need :

    Simple explanation for Output and EventEmitter

    https://angular.io/docs/ts/latest/api/core/index/EventEmitter-class.html

提交回复
热议问题