Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 773
Kristho Avatar asked Jan 27 '26 12:01

Kristho


2 Answers

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

like image 121
IlyaSurmay Avatar answered Jan 29 '26 01:01

IlyaSurmay


Check this component: ngx-modal-dialog. It's css framework agnostic, so you can easily use it with bootstrap or something else. It supports:

  • creation via service
  • single instance check
  • passing in custom title, content component and/or action buttons

Check this page for (kinda) demo: Modal dialog demo

like image 38
Miroslav Jonas Avatar answered Jan 29 '26 02:01

Miroslav Jonas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!