angular-cn/aio/dist/generated/docs/api/router/testing/SpyNgModuleFactoryLoader.json

5 lines
28 KiB
JSON
Raw Permalink Normal View History

{
"id": "api/router/testing/SpyNgModuleFactoryLoader",
"title": "SpyNgModuleFactoryLoader",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/router\", \"name\": \"@angular/router\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/router/testing\", \"name\": \"@angular/router/testing\" } },\n { \"@type\": \"ListItem\", \"position\": 4, \"item\": { \"@id\": \"https://angular.io/api/router/testing/SpyNgModuleFactoryLoader\", \"name\": \"SpyNgModuleFactoryLoader\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/router\">@angular/router</a> > <a href=\"api/router/testing\">@angular/router/testing</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/router/testing/src/router_testing_module.ts?message=docs(router)%3A%20describe%20your%20change...#L13-L79\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/router/testing/src/router_testing_module.ts#L13-L79\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"spyngmodulefactoryloader\">SpyNgModuleFactoryLoader<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/SpyNgModuleFactoryLoader#spyngmodulefactoryloader\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label class\">class</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Allows to simulate the loading of ng modules in tests.</p>\n\n <p><a href=\"api/router/testing/SpyNgModuleFactoryLoader#description\">See more...</a></p>\n </section>\n \n \n \n <section class=\"class-overview\">\n<code-example language=\"ts\" hidecopy=\"true\">\nclass <a href=\"api/router/testing/SpyNgModuleFactoryLoader\" class=\"code-anchor\">SpyNgModuleFactoryLoader</a> implements <a class=\"code-anchor\" href=\"api/core/NgModuleFactoryLoader\">NgModuleFactoryLoader</a> {\n <a class=\"code-anchor\" href=\"api/router/testing/SpyNgModuleFactoryLoader#stubbedModules\"><span class=\"member-name\">stubbedModules</span>: {...}</a>\n <a class=\"code-anchor\" href=\"api/router/testing/SpyNgModuleFactoryLoader#load\"><span class=\"member-name\">load</span>(path: string): Promise&#x3C;NgModuleFactory&#x3C;any>></a>\n}\n</code-example>\n\n \n \n\n</section>\n\n\n \n\n \n \n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/router/testing/SpyNgModuleFactoryLoader#description\"><i class=\"material-icons\">link</i></a></h2>\n <code-example>\nconst loader = TestBed.inject(<a href=\"api/core/NgModuleFactoryLoader\" class=\"code-anchor\">NgModuleFactoryLoader</a>);\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({template: 'lazy-loaded'})\nclass LazyLoadedComponent {}\n@<a href=\"api/core/NgModule\" class=\"code-anchor\">NgModule</a>({\n declarations: [LazyLoadedComponent],\n imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]\n})\n\nclass LoadedModule {}\n\n// sets up stubbedModules\nloader.stubbedModules = {lazyModule: LoadedModule};\n\nrouter.resetConfig([\n {path: 'lazy', loadChildren: 'lazyModule'},\n]);\n\nrouter.navigateByUrl('/lazy/loaded');\
}