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

Commit b1e98b1

Browse files
committed
fix(modal): fix allowing promises to be resolved
- Wrap values otherwise and push to resolve handler Closes #4310 Fixes #4309
1 parent bf63cef commit b1e98b1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/modal/modal.js

+2
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ angular.module('ui.bootstrap.modal', [])
606606
promisesArr.push($q.when($injector.invoke(value)));
607607
} else if (angular.isString(value)) {
608608
promisesArr.push($q.when($injector.get(value)));
609+
} else {
610+
promisesArr.push($q.when(value));
609611
}
610612
});
611613
return promisesArr;

src/modal/test/modal.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,19 @@ describe('$modal', function () {
615615
expect($document).toHaveModalOpenWithContent('Content from resolve', 'div');
616616
});
617617

618+
it('should resolve promises as promises', function() {
619+
open({
620+
controller: function($scope, $foo) {
621+
$scope.value = 'Content from resolve';
622+
expect($foo).toBe('bar');
623+
},
624+
resolve: {
625+
$foo: $q.when('bar')
626+
},
627+
template: '<div>{{value}}</div>'
628+
});
629+
});
630+
618631
it('should delay showing modal if one of the resolves is a promise', function() {
619632
open(modalDefinition('<div>{{value}}</div>', {
620633
value: function() {

0 commit comments

Comments
 (0)