angular js: Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

Vinodh picture Vinodh · Jan 16, 2014 · Viewed 51.3k times · Source

Am using the angular bootstrap to present a modal. But my requirement is to prevent pop-up dismissal when clicking outside the modal, or when the escape key is pressed.

I followed the tutorial on the angular bootstrap site :http://angular-ui.github.io/bootstrap/

enter image description here

Answer

CD.. picture CD.. · Jan 16, 2014

Use:

backdrop: 'static'

backdrop - controls presence of a backdrop. Allowed values: true (default), false (no backdrop), 'static' - backdrop is present but modal window is not closed when clicking outside of the modal window.

For example:

$modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl,
      backdrop: 'static'
    })