Angular: Pass data from Material Dialog to component, which didn't open the dialog

前端 未结 3 859
陌清茗
陌清茗 2020-12-12 02:56

I have a network.component which opens my dialog send-tx-dialog.component. The user fills the send-tx-dialog with information. I want to send that information to another com

3条回答
  •  孤城傲影
    2020-12-12 03:36

    You should use shared service. In ngAfterViewInit subscribe dialog component to property you want to listen in shared service. In parent component call shared service method that will set property in shared service. Property should be of a type Subject (rxjs)

    Take a look at this post: and you will understand everything. Section with shared service. https://netbasal.com/event-emitters-in-angular-13e84ee8d28c Just make sure that you subscribe in ngAfterViewInit in dialog component.

提交回复
热议问题