Title: Feature request : Allow properties Injection · Issue #34425 · angular/angular · GitHub
Open Graph Title: Feature request : Allow properties Injection · Issue #34425 · angular/angular
X Title: Feature request : Allow properties Injection · Issue #34425 · angular/angular
Description: 🚀 feature request [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Performance issue [x] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit ...
Open Graph Description: 🚀 feature request [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Performance issue [x] Feature request [ ] Documentation issue or request [ ] ...
X Description: 🚀 feature request [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Performance issue [x] Feature request [ ] Documentation issue or request [ ] ...
Opengraph URL: https://github.com/angular/angular/issues/34425
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request : Allow properties Injection","articleBody":"# 🚀 feature request\r\n```\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[ ] Bug report \r\n[ ] Performance issue\r\n[x] 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[ ] Other... Please describe:\r\n```\r\n\r\n\r\n### Description\r\nGive the possibility to inject somthing without using constructor\r\n\r\n### Current behavior\r\nAll the dependencies must be injected in constructor:\r\n\r\n\r\n### Expected behavior\r\nAdd new annotation ```@Autowire``` for the property which can be present with ```@Optional```, for example:\r\n```\r\nexport class MyClass {\r\n @Autowire\r\n private mainClass: MainClass;\r\n}\r\n```\r\n### Current solution\r\n\r\n1. Defining a class SingletonLocator\r\n```\r\nexport class SingletonLocator {\r\n public static injector: Injector = undefined;\r\n}\r\n```\r\n2. Add in AppModule\r\n```\r\nexport class AppModule {\r\n constructor(injector: Injector) {\r\n SingletonLocator.injector = injector;\r\n }\r\n}\r\n```\r\n3. Retrive Singleton in a Component\r\n```\r\n@Component(..)\r\nexport class MyComponent {\r\n \r\n private myService: MyService;\r\n\r\n constructor() {\r\n this.myService = SingletonLocator.get(MyService);\r\n }\r\n}\r\n```","author":{"url":"https://github.com/abdelmoez-guetat","@type":"Person","name":"abdelmoez-guetat"},"datePublished":"2019-12-16T13:00:45Z","url":"https://github.com/angular/angular/issues/34425"}
| 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:1d51d248-74c1-5cc8-afe8-9e8d657bc6c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AEAE:FC5BE:24A2717:30A3D60:6B0199C0 |
| html-safe-nonce | 7c58b00f6d442d25e905b4c5779a73ad83a4cbe7d7e18c2a90572abe860923d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUFFOkZDNUJFOjI0QTI3MTc6MzBBM0Q2MDo2QjAxOTlDMCIsInZpc2l0b3JfaWQiOiI4ODI1MTk1NjIzNjE2NzE1MjAwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5f2e295abd348b3ea58eff3fe3b67dda29e2fbf4a45357147e795aeade4bf1b3 |
| hovercard-subject-tag | issue:538397802 |
| 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/34425/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32f41e7dce1001f3b200a0a74282c6299d01795bfb95fada785ca8d747f790cd/angular/angular/issues/34425 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32f41e7dce1001f3b200a0a74282c6299d01795bfb95fada785ca8d747f790cd/angular/angular/issues/34425 |
| og:image:alt | 🚀 feature request [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [ ] Performance issue [x] Feature request [ ] Documentation issue or request [ ] ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abdelmoez-guetat |
| 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