Search code examples
angulartypescriptngx-bootstrap

How to make a general modal dialog service for opening confirm dialogs?


What would be the best way to implement a general Angular 2+ (v5 in my app) service for opening a BootstrapV4 modal with ngx-bootstrap?

I need a general modal dialog which can take a string Input (title of a model) and EventEmitter Output (with a boolean value) that can be used for confirmation of deleting an item and I do not want to create a new dialog every time this pattern occur.

I know how to use the BsModalService for opening a modal from a component, but how can I make it reusable?


Solution

  • I'm sure you can build this service on top of BsModalService.

    Examples:

    https://valor-software.com/ngx-bootstrap/#/modals#service-component

    https://valor-software.com/ngx-bootstrap/#/modals#confirm-window