I am trying to make a reusable modal component that can be called from the same modal itself.
How I can configure the component and modal such that when the reusable component opens up the older instance will get closed directly?
Below is my stackblitz.
https://stackblitz.com/edit/angular-nested-component-modal-ngx-bootstrap-n
I would use one modal...
Here is the strategy
Lets begin by defining our Service
my.service.ts
So we have defined a show method that will set some variabes (
component,configurationandtitle)We have also defined a subject
modalOpen$. Now any property that subscribes to this will be informed when a user has opened a new modalapp.component.ts
Here we subscribe to
modalOpen$and open or close the component providedany-other.component.ts
In other components, we can now use our
showmethod as specified aboveSee Demo Here