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

Commit 8936885

Browse files
committedAug 7, 2015
feat(modal): allow users to resolve with strings
- Allows users to specify a string reference to a service for injection Closes #2676 Closes #4124
1 parent 3c58a73 commit 8936885

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

Diff for: ‎src/modal/modal.js

+2
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ angular.module('ui.bootstrap.modal', [])
538538
angular.forEach(resolves, function (value) {
539539
if (angular.isFunction(value) || angular.isArray(value)) {
540540
promisesArr.push($q.when($injector.invoke(value)));
541+
} else if (angular.isString(value)) {
542+
promisesArr.push($q.when($injector.get(value)));
541543
}
542544
});
543545
return promisesArr;

Diff for: ‎src/modal/test/modal.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,21 @@ describe('$modal', function () {
547547
expect($document).toHaveModalOpenWithContent('Content from resolve', 'div');
548548
});
549549

550+
it('should resolve string references to injectables', function () {
551+
open({
552+
controller: function($scope, $foo) {
553+
$scope.value = 'Content from resolve';
554+
expect($foo).toBe($modal);
555+
},
556+
resolve: {
557+
$foo: '$modal'
558+
},
559+
template: '<div>{{value}}</div>'
560+
});
561+
562+
expect($document).toHaveModalOpenWithContent('Content from resolve', 'div');
563+
});
564+
550565
it('should delay showing modal if one of the resolves is a promise', function () {
551566

552567
open(modalDefinition('<div>{{value}}</div>', {

0 commit comments

Comments
 (0)
This repository has been archived.