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

Commit

Permalink
fix(modal): fix allowing promises to be resolved
Browse files Browse the repository at this point in the history
- Wrap values otherwise and push to resolve handler

Closes #4310
Fixes #4309
  • Loading branch information
wesleycho committed Aug 31, 2015
1 parent bf63cef commit b1e98b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit b1e98b1

Please sign in to comment.