fix(router): load route config from async instructions

Previously, async routes generated from links would not load the configs of
their resolved components, which led to broken links in the children of the
async instruction's component.

This commit fixes the bookkeeping in the Router to correctly load the configs.

Fixes internal b/23791558

Closes #4146
This commit is contained in:
Brian Ford
2015-09-11 14:50:41 -07:00
parent 4c2fb1f6e8
commit 5e49d7e624
4 changed files with 36 additions and 5 deletions

View File

@ -249,9 +249,9 @@ export class RouteRegistry {
}
lastInstructionIsTerminal = lastInstruction.component.terminal;
}
if (!lastInstructionIsTerminal) {
if (isPresent(componentCursor) && !lastInstructionIsTerminal) {
throw new BaseException(
`Link "${ListWrapper.toJSON(linkParams)}" does not resolve to a terminal instruction.`);
`Link "${ListWrapper.toJSON(linkParams)}" does not resolve to a terminal or async instruction.`);
}
}

View File

@ -217,7 +217,8 @@ export class Router {
_settleInstruction(instruction: Instruction): Promise<any> {
var unsettledInstructions: Array<Promise<any>> = [];
if (isBlank(instruction.component.componentType)) {
unsettledInstructions.push(instruction.component.resolveComponentType());
unsettledInstructions.push(instruction.component.resolveComponentType().then(
(type: Type) => { this.registry.configFromComponent(type); }));
}
if (isPresent(instruction.child)) {
unsettledInstructions.push(this._settleInstruction(instruction.child));