Title: SkipSelf annotation to get parent component Injector no longer working in Ivy (Angular 9 rc.9) · Issue #34819 · angular/angular · GitHub
Open Graph Title: SkipSelf annotation to get parent component Injector no longer working in Ivy (Angular 9 rc.9) · Issue #34819 · angular/angular
X Title: SkipSelf annotation to get parent component Injector no longer working in Ivy (Angular 9 rc.9) · Issue #34819 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? Yes, with Angular 8 this was still possible. Description I have a component B that is a child of component A. With previous Angular versions...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? Yes, with Angular 8 this was still possible. Description I have a component B that is a child of com...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? Yes, with Angular 8 this was still possible. Description I have a component B that is a child of com...
Opengraph URL: https://github.com/angular/angular/issues/34819
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SkipSelf annotation to get parent component Injector no longer working in Ivy (Angular 9 rc.9)","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/core\r\n\r\n### Is this a regression?\r\nYes, with Angular 8 this was still possible.\r\n\r\n### Description\r\nI have a component B that is a child of component A. With previous Angular versions I was able to inject the `Injector` of component A into component B by simply using the `@SkipSelf` annotation on the injected service. With that, I could then resolve services in the context of the parent component.\r\n\r\nIn my use case, both A and B provide the same injection token with different fixed values and component B needs to know what this value was for its parent component.\r\n\r\n\r\n## 🔬 Minimal Reproduction\r\nhttps://stackblitz.com/edit/angular-parent-injector-gx5pha\r\n\r\nThe example on StackBlitz is of course in Angular 8 (since I can't seem to do Angular 9 rc projects) and works as expected. The output on the console is:\r\n\r\n\u003cpre>\u003ccode>\r\nthis is \"HELLO COMPONENT\" and parent has name \"THIS IS ROOT\"\r\nthis is \"HELLO COMPONENT\" and parent has name \"THIS IS ROOT\"\r\n\u003c/code>\u003c/pre>\r\n\r\nWhen I download the example and upgrade it to Angular 9 rc.9 I get different output:\r\n\r\n\u003cpre>\u003ccode>\r\nthis is \"HELLO COMPONENT\" and parent has name \"THIS IS ROOT\"\r\nthis is \"HELLO COMPONENT\" and parent has name \"HELLO COMPONENT\"\r\n\u003c/code>\u003c/pre>\r\n\r\nThe second line is produced with the parent `Injector` injection approach.\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\nI tested this with Angular 9 rc.7, rc.8 and rc.9 and the example fails in all of them.\r\n\r\n**Anything else relevant?**\r\nIn the past I have tried other aproaches to solve this issue, one of them was to use the `Injector.get` method and specifying the `InjectFlags` argument as documented in the [Injector](https://angular.io/api/core/Injector). It seems that in all versions of Angular (that I tested), the injector instance that I get when requesting an `Injector` on a component simply _ignores_ the inject flags - in the source code I can see that the method simply does not use this argument. Somehow I find this very weird since the documentation does not seem to mention that.","author":{"url":"https://github.com/elca-lan","@type":"Person","name":"elca-lan"},"datePublished":"2020-01-16T19:50:18Z","url":"https://github.com/angular/angular/issues/34819"}
| 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:4556d72a-b005-af55-1385-a50e6b5ad742 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D236:134361:14B81E3:1B473F6:6B012559 |
| html-safe-nonce | bb414907ded86e11462e4ddab2e5a55b91d120b7bab428da5eb02a9252f2eb6b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjM2OjEzNDM2MToxNEI4MUUzOjFCNDczRjY6NkIwMTI1NTkiLCJ2aXNpdG9yX2lkIjoiODQyNjQ0NjU5MzkzMDc4NjE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d5af792e38a7b12c3260ed85ede2fbbcb090ee42e78c9efbaa236b26b9f71cbe |
| hovercard-subject-tag | issue:551018154 |
| 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/34819/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5fa0683cd1833d0de8dd6db1a5d7bb207ed88011610cfe7f9579accfbd75a3e0/angular/angular/issues/34819 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5fa0683cd1833d0de8dd6db1a5d7bb207ed88011610cfe7f9579accfbd75a3e0/angular/angular/issues/34819 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? Yes, with Angular 8 this was still possible. Description I have a component B that is a child of com... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | elca-lan |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width