valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

How to configure a modal to always have backdrop = 'static' #5409

Open williamxsp opened 4 years ago

williamxsp commented 4 years ago

I'd like to have a global config for all modals to have backdrop as 'static' so I dont have to set at each new modal. Is it possible? (I have several Modal Components created)

this.modalRef = this.modalService.show(ModalVideoComponent, {
      initialState: {
        video: video
      },
      class: 'modal-md',
      backdrop: 'static'
    });
StevenGlrz commented 4 years ago

If you want a hack around it you can do this in app.component.ts or main.ts

modalConfigDefaults.backdrop = 'static';

we should really be provided with a DI solution though.

williamxsp commented 4 years ago

What should I study to learn how to solve this using dependency injection so I can create a PR?

blandyuk commented 2 months ago

Old one, but this can be done via your layout/base page for the whole site. Just include this in your JavaScript at the bottom:

$('.modal').attr('data-backdrop', 'static'); $('.modal').attr('data-keyboard', 'false');