Closed
Description
When the resolve map of a state is defined as follows:
resolve: {
value: 'foo'
}
then 'foo' is supposed to be an alias to a service, that will be called by ui-router, and return a value or a promise. However, that doesn't work (
Link to plunkr).
The line 130 of angular-ui-router.js is suspect:
plan.push(key, [ function() { return $injector.get(key); }], NO_DEPENDENCIES);
Indeed, instead of getting the service from the $injector using the value of the map attribute, it gets it using the key.
I think the following lines:
if (isString(value)) {
plan.push(key, [ function() { return $injector.get(key); }], NO_DEPENDENCIES);
} else {
var params = $injector.annotate(value);
forEach(params, function (param) {
if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param);
});
plan.push(key, value, params);
}
should be replaced with:
var fn = value;
if (isString(value)) {
fn = $injector.get(value);
}
var params = $injector.annotate(fn);
forEach(params, function (param) {
if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param);
});
plan.push(key, fn, params);
Metadata
Metadata
Assignees
Labels
No labels