I have the following markup to display any component within a lightbox:
<lightbox> <some-comp></some-comp> </lightbox> I am trying to find the more generic and Angular way for both components to communicate (I have read https://angular.io/guide/component-interaction). For instance, the child component might say to the lightbox:
- My content is large so you need to expand.
- I contain a form and here is the data submitted via the form.
- Etc.
IMPORTANT. The lightbox doesn't know in advance which type of component it will hold.
I can make it work by injecting a service in both components and the service contains a Subject that serves as a communication bus between the two components (this solution is described in the docs).
But is there another way? I am developing a UI component library and the service solution forces the users of the library to inject and manipulate a service in every component they display in the lightbox. I'd like to avoid that.
(Another idea that I had was for the lightbox to gain access to its child component and subscribe to a specific property on that component, but it's hard to do in a generic manner.)