Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 8e7fbf0

Browse files
fix(modal): allow replacing object with default options
Closes #967
1 parent 8d153ac commit 8e7fbf0

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/modal/modal.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,11 @@ angular.module('ui.bootstrap.modal', [])
208208

209209
.provider('$modal', function () {
210210

211-
var defaultOptions = {
212-
backdrop: true, //can be also false or 'static'
213-
keyboard: true
214-
};
215-
216-
return {
217-
options: defaultOptions,
211+
var $modalProvider = {
212+
options: {
213+
backdrop: true, //can be also false or 'static'
214+
keyboard: true
215+
},
218216
$get: ['$injector', '$rootScope', '$q', '$http', '$templateCache', '$controller', '$modalStack',
219217
function ($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) {
220218

@@ -255,7 +253,7 @@ angular.module('ui.bootstrap.modal', [])
255253
};
256254

257255
//merge and clean up options
258-
modalOptions = angular.extend({}, defaultOptions, modalOptions);
256+
modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
259257
modalOptions.resolve = modalOptions.resolve || {};
260258

261259
//verify options
@@ -312,4 +310,6 @@ angular.module('ui.bootstrap.modal', [])
312310
return $modal;
313311
}]
314312
};
313+
314+
return $modalProvider;
315315
});

src/modal/test/modal.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ describe('$modal', function () {
202202
expect($document).toHaveModalOpenWithContent('Content', 'div');
203203
expect($document).not.toHaveBackdrop();
204204
});
205+
206+
it('should accept new objects with default options in a provider', function () {
207+
208+
$modalProvider.options = {
209+
backdrop: false
210+
};
211+
var modal = open({template: '<div>Content</div>'});
212+
213+
expect($document).toHaveModalOpenWithContent('Content', 'div');
214+
expect($document).not.toHaveBackdrop();
215+
});
216+
205217
});
206218

207219
describe('option by option', function () {

0 commit comments

Comments
 (0)