Angular 2/4 communication between two component via a shared service

后端 未结 5 1910
不知归路
不知归路 2020-12-11 13:32

I am trying to build a simple shopping cart application. I have two components and a cart service like following.



<         


        
5条回答
  •  长情又很酷
    2020-12-11 14:07

    In the header, you must subscribe to some event in the Shared Service. The same event will be emitted from your cart component.

    Please have a look at this plunkr https://plnkr.co/edit/LS1uqB?p=preview

提交回复
热议问题