Title: Add flag to ng generate component that skips adding ngOnInit() interface. · Issue #23678 · angular/angular-cli · GitHub
Open Graph Title: Add flag to ng generate component that skips adding ngOnInit() interface. · Issue #23678 · angular/angular-cli
X Title: Add flag to ng generate component that skips adding ngOnInit() interface. · Issue #23678 · angular/angular-cli
Description: 🚀 Feature request Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description Generating components with ng g c component-name always generates a component implementing ...
Open Graph Description: 🚀 Feature request Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description Generating components with ng g c component-name al...
X Description: 🚀 Feature request Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description Generating components with ng g c component-name al...
Opengraph URL: https://github.com/angular/angular-cli/issues/23678
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add flag to ng generate component that skips adding ngOnInit() interface.","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n# 🚀 Feature request\r\n\r\n### Command (mark with an `x`)\r\n\r\n\u003c!-- Can you pin-point the command or commands that are relevant for this feature request? -->\r\n\u003c!-- ✍️edit: -->\r\n\r\n- [ ] new\r\n- [ ] build\r\n- [ ] serve\r\n- [ ] test\r\n- [ ] e2e\r\n- [x] generate\r\n- [ ] add\r\n- [ ] update\r\n- [ ] lint\r\n- [ ] extract-i18n\r\n- [ ] run\r\n- [ ] config\r\n- [ ] help\r\n- [ ] version\r\n- [ ] doc\r\n\r\n### Description\r\n\r\nGenerating components with `ng g c component-name` always generates a component implementing `ngOnInit()` interface.\r\n\r\nMany components do not benefit from implementing such interface. A good example might be a dumb component, that uses mostly `@Input()` and `@Output()`.\r\n\r\nRight now there is no way to override this behaviour so if you want to generate a dumb component, you need to:\r\n\r\n1. remove `ngOnInit()` method, \r\n2. remove `implements OnInit` clause from the component class,\r\n3. remove the OnInit import from '@angular/core';\r\n\r\nThis has to be repeated for every component generated, so it gets old really fast 🤷 \r\n\r\n### Describe the solution you'd like\r\n\r\nIdeally, there should be an option to generate a component that does not implement the `ngOnInit()` hook.\r\n\r\nMaybe something like this could work:\r\n```ng g c component-name --skip-on-init``` or ```ng g c component-name --skip-lifecycle```\r\n\r\nIt would match the naming of flags such as `--skip-tests` or `--skip-selector`.\r\n\r\n","author":{"url":"https://github.com/realtomaszkula","@type":"Person","name":"realtomaszkula"},"datePublished":"2022-08-03T12:57:30Z","url":"https://github.com/angular/angular-cli/issues/23678"}
| 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:11655c27-9051-d011-2b80-accc1ca9bad6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8228:CC1A4:DC965C:1198FD8:6B01051E |
| html-safe-nonce | 97ae0274ec8675188141336642710e6e759449b60fe05fa1ac2fee17507c580f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjI4OkNDMUE0OkRDOTY1QzoxMTk4RkQ4OjZCMDEwNTFFIiwidmlzaXRvcl9pZCI6IjI2MTQxOTA5OTI1MDAyNjIxNzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0bc004ad5e2336367979111968013a393e8c6384ad1f11f75055809a22e93852 |
| hovercard-subject-tag | issue:1327180495 |
| 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-cli/23678/issue_layout |
| twitter:image | https://opengraph.githubassets.com/285a90dc5a430201c014d895c0fc583cf0b102390efc103164586a4b22e1e27b/angular/angular-cli/issues/23678 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/285a90dc5a430201c014d895c0fc583cf0b102390efc103164586a4b22e1e27b/angular/angular-cli/issues/23678 |
| og:image:alt | 🚀 Feature request Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description Generating components with ng g c component-name al... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | realtomaszkula |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width