Title: canLoad guard does not subscribe to Observable
Open Graph Title: canLoad guard does not subscribe to Observable
X Title: canLoad guard does not subscribe to Observable
Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here...
Open Graph Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => P...
X Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request ...
Opengraph URL: https://github.com/angular/angular/issues/18991
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"canLoad guard does not subscribe to Observable\u003cboolean>","articleBody":"## I'm submitting a...\r\n\u003c!-- Check one of the following options with \"x\" -->\r\n\u003cpre>\u003ccode>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[x] Bug report\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n\u003c/code>\u003c/pre>\r\n\r\n## Current behavior\r\nWhen passing an Observable to the `canLoad` guard for a lazyly loaded module `routerLink` stops navigating to any route even if the boolean in `Observable\u003cboolean>` is `true`. **No** error messages in console.\r\n\r\n**app-routing.module**:\r\n```typescript\r\nconst routes: Routes = [\r\n {\r\n path: '',\r\n component: SomeAComponent,\r\n pathMatch: 'full'\r\n },\r\n {\r\n path: 'someb',\r\n component: SomeBComponent,\r\n canActivate: [\r\n AuthGuard\r\n ],\r\n },\r\n {\r\n path: 'lazy',\r\n loadChildren: './lazy/lazy.module#LazyModule',\r\n canLoad: [\r\n AuthGuard\r\n ]\r\n },\r\n {\r\n path: '**',\r\n redirectTo: '/'\r\n }\r\n];\r\n```\r\n\r\n**auth.guard**:\r\n```typescript\r\n@Injectable()\r\nexport class AuthGuard implements CanLoad, CanActivate {\r\n\r\n /* \r\n * @angular-redux/store\r\n * false --> next() --> true --> ...\r\n */\r\n @select() readonly authenticated$: Observable\u003cboolean>;\r\n\r\n canLoad(): Observable\u003cboolean> | boolean {\r\n // return true; // WORKS\r\n return this.authenticated$; // ERROR: all routing stops from and to the current page\r\n }\r\n\r\n canActivate(): Observable\u003cboolean> | boolean {\r\n // return true; // WORKS\r\n return this.authenticated$; // WORKS\r\n }\r\n\r\n}\r\n```\r\n\r\n**lazy-routing.module**:\r\n```typescript\r\n//...\r\nconst routes: Routes = [\r\n {\r\n path: '',\r\n component: LazyComponent\r\n }\r\n];\r\n//...\r\n```\r\n\r\n## Expected behavior\r\nLike the `canActivate` guard the `canLoad`guard should subscribe to the Observable.\r\n\r\n\r\n## Minimal reproduction of the problem with instructions\r\n* set value of the `authenticated$` Observable to true\r\n* lazy load a module and protect it via `canLoad` guard\r\n* navigate to the lazy and protected module via `\u003ca routerLink=\"/lazy\">Lazy\u003c/a>`\r\n=> **all** navigation stops.\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\nAngular version: 4.3.6\r\n\u003c!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\nBrowser:\r\n- [x] Chrome (desktop) version 60.0.3112.113\r\n- [ ] Chrome (Android) version XX\r\n- [ ] Chrome (iOS) version XX\r\n- [x] Firefox version 55.0.3\r\n- [x] Safari (desktop) version 10.1.2 (12603.3.8)\r\n- [ ] Safari (iOS) version XX\r\n- [ ] IE version XX\r\n- [ ] Edge version XX\r\n \r\nFor Tooling issues:\r\n- Node version: v8.4.0\r\n- Platform: MacOS 10.12.6\r\n\r\nOthers:\r\n* @angular-redux/router@6.3.1\r\n* @angular-redux/store@6.5.7\r\n* redux@3.7.2\r\n* rxjs@5.4.3\r\n* typescript@2.3.4\r\n\u003c/code>\u003c/pre>\r\n","author":{"url":"https://github.com/markusfalk","@type":"Person","name":"markusfalk"},"datePublished":"2017-09-01T08:46:31Z","url":"https://github.com/angular/angular/issues/18991"}
| 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:507d3028-e0b8-fa14-062e-971291ee29a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED84:21E3E7:CA7EE1:10C80E7:6B00F641 |
| html-safe-nonce | 364d63273a2d926e86bda09d91cbe5b11e46c6e8e9c58732ad6879f9520cb089 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDg0OjIxRTNFNzpDQTdFRTE6MTBDODBFNzo2QjAwRjY0MSIsInZpc2l0b3JfaWQiOiI3NDMxOTIyNzAyNTM5MDkzNTY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 31c3d7013267668e4e67357dfaf42e3cf7fbb2b8e88dd35dddeed8ef7e5d939c |
| hovercard-subject-tag | issue:254575385 |
| 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/18991/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c2b1a2860154778d0afb37600dc4cf21c62f2e432a3454745425ccd5bf3c6579/angular/angular/issues/18991 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c2b1a2860154778d0afb37600dc4cf21c62f2e432a3454745425ccd5bf3c6579/angular/angular/issues/18991 |
| og:image:alt | I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => P... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markusfalk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width