Skip to content

Commit 4cdadcf

Browse files
committed
fix($resolve): resolve factories from string names
$resolve now correctly executes factory functions when provided the name of the factory as a string. Closes #449
1 parent 438a62a commit 4cdadcf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: src/resolve.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function $Resolve( $q, $injector) {
4242
visited[key] = VISIT_IN_PROGRESS;
4343

4444
if (isString(value)) {
45-
plan.push(key, [ function() { return $injector.get(key); }], NO_DEPENDENCIES);
45+
plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES);
4646
} else {
4747
var params = $injector.annotate(value);
4848
forEach(params, function (param) {

Diff for: test/resolveSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ describe("resolve", function () {
33
var $r, tick;
44

55
beforeEach(module('ui.router.util'));
6+
beforeEach(module(function($provide) {
7+
$provide.factory('Foo', function() {
8+
return "Working";
9+
});
10+
}));
11+
612
beforeEach(inject(function($resolve, $q) {
713
$r = $resolve;
814
tick = $q.flush;
@@ -292,6 +298,15 @@ describe("resolve", function () {
292298
r({ what: 'hi' });
293299
expect(trace).toEqual([ 'a: 1', 'a: hi' ]);
294300
});
301+
302+
it("resolves values from string factory names", function () {
303+
var result, r = $r.study({ foo: "Foo" })().then(function(values) {
304+
result = values['foo'];
305+
});
306+
tick();
307+
308+
expect(result).toBe("Working");
309+
});
295310
});
296311
});
297312

0 commit comments

Comments
 (0)