diff --git a/modules/@angular/router/src/apply_redirects.ts b/modules/@angular/router/src/apply_redirects.ts index 694c051394..3b3257b995 100644 --- a/modules/@angular/router/src/apply_redirects.ts +++ b/modules/@angular/router/src/apply_redirects.ts @@ -211,7 +211,14 @@ class ApplyRedirects { injector: Injector, rawSegmentGroup: UrlSegmentGroup, route: Route, segments: UrlSegment[]): Observable { if (route.path === '**') { - return of (new UrlSegmentGroup(segments, {})); + if (route.loadChildren) { + return map.call(this.configLoader.load(injector, route.loadChildren), (r: any) => { + (route)._loadedConfig = r; + return of (new UrlSegmentGroup(segments, {})); + }); + } else { + return of (new UrlSegmentGroup(segments, {})); + } } else { const {matched, consumedSegments, lastChild} = match(rawSegmentGroup, route, segments); diff --git a/modules/@angular/router/test/apply_redirects.spec.ts b/modules/@angular/router/test/apply_redirects.spec.ts index ceae5f3cc2..a6ab23c4a4 100644 --- a/modules/@angular/router/test/apply_redirects.spec.ts +++ b/modules/@angular/router/test/apply_redirects.spec.ts @@ -292,6 +292,19 @@ describe('applyRedirects', () => { }, (e) => { throw 'Should not reach'; }); }); + + it('should load the configuration of a whilecard route', () => { + const loadedConfig = new LoadedRouterConfig( + [{path: '', component: ComponentB}], 'stubInjector', 'stubFactoryResolver'); + + const loader = {load: (injector: any, p: any) => of (loadedConfig)}; + + const config = [{path: '**', loadChildren: 'children'}]; + + applyRedirects('providedInjector', loader, tree('xyz'), config).forEach(r => { + expect((config[0])._loadedConfig).toBe(loadedConfig); + }); + }); }); describe('empty paths', () => {