fix(router): fix lazy loaded module with wildcard route (#13649)
Closes #12955
This commit is contained in:
parent
eed83443b8
commit
0eca960494
@ -235,7 +235,7 @@ class ApplyRedirects {
|
|||||||
if (route.loadChildren) {
|
if (route.loadChildren) {
|
||||||
return map.call(this.configLoader.load(injector, route.loadChildren), (r: any) => {
|
return map.call(this.configLoader.load(injector, route.loadChildren), (r: any) => {
|
||||||
(<any>route)._loadedConfig = r;
|
(<any>route)._loadedConfig = r;
|
||||||
return of (new UrlSegmentGroup(segments, {}));
|
return new UrlSegmentGroup(segments, {});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return of (new UrlSegmentGroup(segments, {}));
|
return of (new UrlSegmentGroup(segments, {}));
|
||||||
|
@ -2378,6 +2378,32 @@ describe('Integration', () => {
|
|||||||
expect(location.path()).toEqual('/lazy/loaded');
|
expect(location.path()).toEqual('/lazy/loaded');
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
it('should work with wildcard route',
|
||||||
|
fakeAsync(inject(
|
||||||
|
[Router, Location, NgModuleFactoryLoader],
|
||||||
|
(router: Router, location: Location, loader: SpyNgModuleFactoryLoader) => {
|
||||||
|
@Component({selector: 'lazy', template: 'lazy-loaded'})
|
||||||
|
class LazyLoadedComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [LazyLoadedComponent],
|
||||||
|
imports: [RouterModule.forChild([{path: '', component: LazyLoadedComponent}])],
|
||||||
|
})
|
||||||
|
class LoadedModule {
|
||||||
|
}
|
||||||
|
|
||||||
|
loader.stubbedModules = {lazy: LoadedModule};
|
||||||
|
const fixture = createRoot(router, RootCmp);
|
||||||
|
|
||||||
|
router.resetConfig([{path: '**', loadChildren: 'lazy'}]);
|
||||||
|
|
||||||
|
router.navigateByUrl('/lazy');
|
||||||
|
advance(fixture);
|
||||||
|
|
||||||
|
expect(location.path()).toEqual('/lazy');
|
||||||
|
})));
|
||||||
|
|
||||||
describe('preloading', () => {
|
describe('preloading', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule(
|
TestBed.configureTestingModule(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user