feat(router): add support for lazily loaded modules

This commit is contained in:
vsavkin
2016-07-06 11:02:16 -07:00
parent 6fcf962fb5
commit 8ebb8e44c8
13 changed files with 431 additions and 140 deletions

View File

@ -122,7 +122,7 @@ function processPathsWithParamsAgainstRoute(
const {consumedPaths, parameters, lastChild} = match(rawSegment, route, paths);
const rawSlicedPath = paths.slice(lastChild);
const childConfig = route.children ? route.children : [];
const childConfig = getChildConfig(route);
const newInherited = route.component ?
InheritedFromParent.empty :
new InheritedFromParent(inherited, parameters, getData(route), newInheritedResolve);
@ -149,6 +149,16 @@ function processPathsWithParamsAgainstRoute(
}
}
function getChildConfig(route: Route): Route[] {
if (route.children) {
return route.children;
} else if (route.mountChildren) {
return (<any>route)._loadedConfig.routes;
} else {
return [];
}
}
function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) {
if (route.path === '') {
if ((route.terminal || route.pathMatch === 'full') &&