Title: AoT compiled components do not call inherited lifecycle hooks · Issue #12922 · angular/angular · GitHub
Open Graph Title: AoT compiled components do not call inherited lifecycle hooks · Issue #12922 · angular/angular
X Title: AoT compiled components do not call inherited lifecycle hooks · Issue #12922 · 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/12922
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AoT compiled components do not call inherited lifecycle hooks","articleBody":"**I'm submitting a ...** (check one with \"x\")\r\n```\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature 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```\r\n\r\n**Current behavior**\r\nThe AoT compiler does not look up the inheritance tree when checking for lifecycle hooks, which results in different behaviour than when compiling JiT.\r\n\r\n**Expected behavior**\r\n\r\nThe AoT compiler should search all super classes of a component for implementation of lifecycle hooks.\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n\r\n```\r\nclass BaseComponent implements OnInit {\r\n ngOnInit() {\r\n // do something important\r\n }\r\n}\r\n\r\n@Component( ... )\r\nclass ConcreteComponent extends BaseComponent {\r\n ...\r\n}\r\n```\r\n\r\nWhen running in JiT mode, the `ngOnInit()` method will be called when the `ConcreteComponent` is instantiated. But in AoT mode, the function will not be called.\r\n\r\nCurrently, the workaround is to explicitly implement all the super class hooks:\r\n\r\n```\r\n@Component( ... )\r\nclass ConcreteComponent extends BaseComponent {\r\n ngOnInit() {\r\n super.ngOnInit();\r\n }\r\n}\r\n```\r\n\r\nThis is the case for all the lifecycle hooks, not just `ngOnInit`.\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\nThis is especially important for the `@angular/upgrade/static` library which has a base class, `UpgradeComponent`, for Angular 2 components that are used to upgrade Angular 1 components.\r\n\r\n* **Angular version:** \u003c=2.2.0 (and master at time of writing)\r\n","author":{"url":"https://github.com/petebacondarwin","@type":"Person","name":"petebacondarwin"},"datePublished":"2016-11-16T17:45:17Z","url":"https://github.com/angular/angular/issues/12922"}
| 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:58286248-cd78-300c-66ee-a69aed539b75 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9CD0:7A60E:909B9A:BCE577:6B00DFF0 |
| html-safe-nonce | 7b053514dffaf01810acf9017e683c6652f25788edc4229bf20d29b8d6dd677e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0QwOjdBNjBFOjkwOUI5QTpCQ0U1Nzc6NkIwMERGRjAiLCJ2aXNpdG9yX2lkIjoiMjc3NDI2MzA5NjQ3NzI3ODE5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a7440c2362868c34a69d44c5e2ccc68db7ad11d224773341277e05a7de853c43 |
| hovercard-subject-tag | issue:189786867 |
| 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/12922/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d9e7cf0494088bf19d8a2124e94b83a3bff04e8ae01f74695fce4a26f1a43fb/angular/angular/issues/12922 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d9e7cf0494088bf19d8a2124e94b83a3bff04e8ae01f74695fce4a26f1a43fb/angular/angular/issues/12922 |
| 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 | petebacondarwin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width