mode_edit codeAPI / @angular/router/testingSpyNgModuleFactoryLoaderlinkclass 稳定Allows to simulate the loading of ng modules in tests.class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader { stubbedModules: {...} load(path: string): Promise<NgModuleFactory<any>> }说明linkconst loader = TestBed.get(NgModuleFactoryLoader); @Component({template: 'lazy-loaded'}) class LazyLoadedComponent {} @NgModule({ declarations: [LazyLoadedComponent], imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])] }) class LoadedModule {} // sets up stubbedModules loader.stubbedModules = {lazyModule: LoadedModule}; router.resetConfig([ {path: 'lazy', loadChildren: 'lazyModule'}, ]); router.navigateByUrl('/lazy/loaded');属性link属性名类型说明stubbedModules{ [path: string]: any; }方法linkload() linkmode_edit codeload(path: string): Promise<NgModuleFactory<any>>参数pathType: string.返回值Promise<NgModuleFactory<any>>注解link@Injectable()