Title: (bug)router/AOT Unable to use feature-modules in routing when doing AOT compilation · Issue #11075 · angular/angular · GitHub
Open Graph Title: (bug)router/AOT Unable to use feature-modules in routing when doing AOT compilation · Issue #11075 · angular/angular
X Title: (bug)router/AOT Unable to use feature-modules in routing when doing AOT compilation · Issue #11075 · angular/angular
Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/an...
Open Graph Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support request...
X Description: I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not su...
Opengraph URL: https://github.com/angular/angular/issues/11075
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"(bug)router/AOT Unable to use feature-modules in routing when doing AOT compilation","articleBody":"**I'm submitting a ...** (check one with \"x\")\n\n```\n[x] bug report => search github for a similar issue or PR before submitting\n[ ] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\nWe are using Features-Modules to encapsulate things belonging together and we are using theses Features-Modules in Routing like this:\n\napp.module.ts\n\n``` ts\n@NgModule({\n imports: [SharedModule.forRoot(),\n BrowserModule,\n RouterModule.forRoot(APP_ROUTES)\n ],\n ...\n})\nexport class AppModule {\n}\n\n```\n\napp.routes.ts:\n\n``` ts\nexport function getTasksModule() {\n return TasksModule;\n}\n\nexport const APP_ROUTES: Routes = [\n ...\n {path: 'tasks', canLoad: [LoginGuard], loadChildren: getTasksModule},\n];\n```\n\nthis works fine when not doing AOT. Now when calling\n\n```\n./node_modules/.bin/ngc -p ./src\n```\n\nthe application compiles without errors, but in runtime I get the following exception when enterting the `/tasks` route:\n\n``` ts\nError: Uncaught (in promise): TypeError: r.create is not a function\n at resolvePromise (zone.js:558)\n at zone.js:535\n at ZoneDelegate.invoke (zone.js:332)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (ng_zone_impl.js:41)\n```\n\nafter some debugging it looks like the application get the `TasksModule` where it needs to have the `TasksModuleNgFactory`. So the exception happens in this code:\n\nrouter_config_loader.ts\n\n``` ts\n load(parentInjector: Injector, loadChildren: LoadChildren): Observable\u003cLoadedRouterConfig> {\n return this.loadModuleFactory(loadChildren).map(r => {\n const ref = r.create(parentInjector);\n return new LoadedRouterConfig(\n flatten(ref.injector.get(ROUTES)), ref.injector, ref.componentFactoryResolver);\n });\n }\n```\n\nand r is TasksModule when the exeption occurs.\n\n**Expected/desired behavior**\n\nIt should be possible to use loadChildren in combination with AOT\n\n**What is the motivation / use case for changing the behavior?**\n\nCurrently it's not possible to encapsulate routing into Feature-Modules when using the AOT-compiler\n\n**Please tell us about your environment:**\n- **Angular version:** commit 2b313e49791b932634cc58cf913a8cf867671d37\n- **Browser:** [all ] \n- **Language:** [all ] \n","author":{"url":"https://github.com/choeller","@type":"Person","name":"choeller"},"datePublished":"2016-08-25T14:42:47Z","url":"https://github.com/angular/angular/issues/11075"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:80a14c45-5089-1c1d-c80f-168f9dfc06c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A840:842EC:146C76F:1B47362:6B0130F3 |
| html-safe-nonce | 7201419d2f9056d10c05dc118205e7038d19c245e344ef41d37e4962fe703b24 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODQwOjg0MkVDOjE0NkM3NkY6MUI0NzM2Mjo2QjAxMzBGMyIsInZpc2l0b3JfaWQiOiIzNzg1MjU3NjM0NDIxMDkyNTk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ebeaa9da42d4cac25d2202cab7cc22077480a0ac2bc3b1bf34b55fa93817a65b |
| hovercard-subject-tag | issue:173222678 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/11075/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d1ab04800cb8cea9250ecf393f209474096b68d626b3c6ae221e0fcd558586d/angular/angular/issues/11075 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d1ab04800cb8cea9250ecf393f209474096b68d626b3c6ae221e0fcd558586d/angular/angular/issues/11075 |
| og:image:alt | I'm submitting a ... (check one with "x") [x] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support request... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | choeller |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width