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

fix(modal): fix allowing promises to be resolved #4310

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ angular.module('ui.bootstrap.modal', [])
promisesArr.push($q.when($injector.invoke(value)));
} else if (angular.isString(value)) {
promisesArr.push($q.when($injector.get(value)));
} else {
promisesArr.push($q.when(value));
}
});
return promisesArr;
Expand Down
13 changes: 13 additions & 0 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,19 @@ describe('$modal', function () {
expect($document).toHaveModalOpenWithContent('Content from resolve', 'div');
});

it('should resolve promises as promises', function() {
open({
controller: function($scope, $foo) {
$scope.value = 'Content from resolve';
expect($foo).toBe('bar');
},
resolve: {
$foo: $q.when('bar')
},
template: '<div>{{value}}</div>'
});
});

it('should delay showing modal if one of the resolves is a promise', function() {
open(modalDefinition('<div>{{value}}</div>', {
value: function() {
Expand Down