I am using Angular UI $modal in my project http://angular-ui.github.io/bootstrap/#/modal
I don\'t want user to close the modal by pressing on backdrop. I want a modal
decorator, one of the best features in angular. gives the ability to "patch" 3rd party modules.
Let's say you want this behavior in all of your $modal
references and you don't want to change your calls,
You can write a decorator. that simply adds to options - {backdrop:'static', keyboard:false}
angular.module('ui.bootstrap').config(function ($provide) {
$provide.decorator('$modal', function ($delegate) {
var open = $delegate.open;
$delegate.open = function (options) {
options = angular.extend(options || {}, {
backdrop: 'static',
keyboard: false
});
return open(options);
};
return $delegate;
})
});
$modal
renamed to $uibModal
Online demo - http://plnkr.co/edit/2MWIpOs3uAG5EFQy6Ndn?p=preview