0

I am trying to implement the modal dialog as shown in this post, but I need to call modal.show() from a child several layers below the parent of the modal dialog. I have no idea how to handle this.

Angular 2.0 and Modal Dialog

Community
  • 1
  • 1
Danny Ellis Jr.
  • 1,674
  • 2
  • 23
  • 38

1 Answers1

0

You should create a service for showing modal rather than calling parent. And the modal should be dynamically created and destroyed.

Tuong Le
  • 18,533
  • 11
  • 50
  • 44
  • I get the service part. I don't know what you mean about created and destroyed dynamically. – Danny Ellis Jr. Mar 14 '17 at 23:49
  • Here's an example of how to create a dynamic component: http://blog.rangle.io/dynamically-creating-components-with-angular-2/ What I meant is the service will generate (or tell the parent using Event or Observable ...) to generate a modal component dynamically. – Tuong Le Mar 15 '17 at 00:27
  • I'm a little further away from understanding this fully than I thought. This example does not use a service exactly, and I am having trouble translating this code into a shared service implementation. – Danny Ellis Jr. Mar 15 '17 at 13:18