fix(router): wildcards routes should support lazy loading
Closes #12024
This commit is contained in:
parent
1681e4f57f
commit
40b92ddf21
|
@ -211,7 +211,14 @@ class ApplyRedirects {
|
||||||
injector: Injector, rawSegmentGroup: UrlSegmentGroup, route: Route,
|
injector: Injector, rawSegmentGroup: UrlSegmentGroup, route: Route,
|
||||||
segments: UrlSegment[]): Observable<UrlSegmentGroup> {
|
segments: UrlSegment[]): Observable<UrlSegmentGroup> {
|
||||||
if (route.path === '**') {
|
if (route.path === '**') {
|
||||||
return of (new UrlSegmentGroup(segments, {}));
|
if (route.loadChildren) {
|
||||||
|
return map.call(this.configLoader.load(injector, route.loadChildren), (r: any) => {
|
||||||
|
(<any>route)._loadedConfig = r;
|
||||||
|
return of (new UrlSegmentGroup(segments, {}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return of (new UrlSegmentGroup(segments, {}));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const {matched, consumedSegments, lastChild} = match(rawSegmentGroup, route, segments);
|
const {matched, consumedSegments, lastChild} = match(rawSegmentGroup, route, segments);
|
||||||
|
|
|
@ -292,6 +292,19 @@ describe('applyRedirects', () => {
|
||||||
},
|
},
|
||||||
(e) => { throw 'Should not reach'; });
|
(e) => { throw 'Should not reach'; });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should load the configuration of a whilecard route', () => {
|
||||||
|
const loadedConfig = new LoadedRouterConfig(
|
||||||
|
[{path: '', component: ComponentB}], <any>'stubInjector', <any>'stubFactoryResolver');
|
||||||
|
|
||||||
|
const loader = {load: (injector: any, p: any) => of (loadedConfig)};
|
||||||
|
|
||||||
|
const config = [{path: '**', loadChildren: 'children'}];
|
||||||
|
|
||||||
|
applyRedirects(<any>'providedInjector', <any>loader, tree('xyz'), config).forEach(r => {
|
||||||
|
expect((<any>config[0])._loadedConfig).toBe(loadedConfig);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('empty paths', () => {
|
describe('empty paths', () => {
|
||||||
|
|
Loading…
Reference in New Issue