Closed
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 ngOnInit()
interface.
Many components do not benefit from implementing such interface. A good example might be a dumb component, that uses mostly @Input()
and @Output()
.
Right now there is no way to override this behaviour so if you want to generate a dumb component, you need to:
- remove
ngOnInit()
method, - remove
implements OnInit
clause from the component class, - remove the OnInit import from '@angular/core';
This has to be repeated for every component generated, so it gets old really fast 🤷
Describe the solution you'd like
Ideally, there should be an option to generate a component that does not implement the ngOnInit()
hook.
Maybe something like this could work:
ng g c component-name --skip-on-init
or ng g c component-name --skip-lifecycle
It would match the naming of flags such as --skip-tests
or --skip-selector
.