Angular 2 Sibling Component Communication

前端 未结 12 1556
深忆病人
深忆病人 2020-11-22 06:31

I have a ListComponent. When an item is clicked in ListComponent, the details of that item should be shown in DetailComponent. Both are on the screen at the same time, so

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 07:28

    There is a discussion about it here.

    https://github.com/angular/angular.io/issues/2663

    Alex J's answer is good but it no longer works with current Angular 4 as of July, 2017.

    And this plunker link would demonstrate how to communicate between siblings using shared service and observable.

    https://embed.plnkr.co/P8xCEwSKgcOg07pwDrlO/

提交回复
热议问题