DEV Community

Facundo Ezequiel Diaz Cappella
Facundo Ezequiel Diaz Cappella

Posted on

1

Angular CLI shortcuts for generating components

Sometimes when we need to create a new element, we copy a component and paste renaming the files instead of using the proper command of angular CLI.

I think is important to follow the right approach and use the angular CLI commands because in this way, take it for sure
that you will speed up your times.

For that, I will share with you, what I use the most.

element command short way
Component ng g component nameComponent ng g c nameComponent
Service ng g service nameService ng g s nameService
Enum ng g enum nameEnum ng g e nameEnum
Interface ng g interface nameInterface ng g i
Module ng g module nameModule ng g m nameModule
Guard ng g guard nameGuard ng g g
Pipe ng g pipe namePipe ng g p

Also, we can indicate some options:

--flat -> with this we can generate the element without create a new directory.
--inline-style or -is -> avoid generate the css file
--inline-template or -it -> avoid generate html file
--skip-tests -> avoid generate spec file

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
anduser96 profile image
Andrei Gatej

Thanks for sharing.

There is also one that I found really useful, at least when generating components, and that is the -d(dry run) flag.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay