Patrick Patrick - 4 months ago 51
AngularJS Question

Modal closes when clicked outside (angularjs-- plunker attacked)

I tried various solutions posted online for how to disable modal closing when we clicked outside the modal. I didnt find a working solution.

Can someone please let me know how to achieve it in my case.

http://plnkr.co/edit/DX7My1zuQEeeQTfDOHi9?p=preview

Heres the plunker

$scope.modal = {
title: "Enter Details",
html: true,
show: true,
backdrop:'static',
keyboard:false
};


set this parameter. Yet cldnt get it working.

Answer

You can use data attributes on the button you are clicking to open the modal, it will wire the modal through bootstrap to not close. like this:

<button type="button" class="btn btn-md btn-primary" data-animation="am-flip-x" data-backdrop="static" data-keyboard="false" data-template-url="modal/docs/modal.demo.tpl.html" data-placement="center" bs-modal="modal">Open modal</button>

Notice I added these 2 data attributes:

data-backdrop="static" data-keyboard="false"

Here is your Plunker code edit to keep the modal open: http://plnkr.co/edit/v92LToGz9yc3gCV8tr04?p=preview