I have the following markup to display any component in a lightbox:
<lightbox> <some-comp></some-comp> </lightbox>
I am trying to find a more general and Angular way for the interaction of both components (I read https://angular.io/guide/component-interaction ). For example, a child component might say lightbox:
- My content is great, so you need to expand it.
- I contain the form, and here is the data submitted through the form.
- Etc.
IMPORTANT. A lightbox does not know in advance what type of component it will hold.
I can make it work by introducing the service in both components, and the service contains a Subject , which serves as a communication bus between the two components (this solution is described in the documents ).
But is there any other way? I am developing a library of user interface components, and the solution for the service forces library users to implement and manage services in each component that they display in the lightbox. I would like to avoid this.
(Another idea I got is for a lightbox to access its child component and subscribe to a specific property of that component, but this is difficult to do in general.)
source share