Basic Angular CLI comments

In this blog, I gave you some basic important angular CLI comments that might be very useful for you to create and develop the angular project or application. With the help of below CLI comments you can easily generate the component, service, page and routing module.

Component consists of four files, those are .html, .css, .ts, and spec file. Whenever you create the component manually you have to create those four files and it should be imported in app.module.ts its taking some amount of time. But when you create a component using CLI, CLI will take care of those tasks.

Angular CLI comments

  • Create new angular project
    • ng new <project_name>
  • Create new component
    • ng generate component <component_name> (or) ng g c <component_name>
  • Create new service
    • ng generate service <service_name> (or) ng g s <service_name>
  • Create new Page
    • ng generate page <page_name> (or) ng g p <page_name>
  • Add routing module
    • ng generate module <module_name> –routing (or) ng g m <module_name> –routing
  • Run the application in default port <4200>
    • ng serve
  • Run the application in specific port
    • ng serve –port 4100
  • Build the angular project for DEV environment
    • ng build
  • Build the angular project for PROD environment
    • ng build –prod
  • Check angular version
    • ng version
  • Add the external module in angular project.
    • ng add <therid_partiy_module>

2 Comments on “Basic Angular CLI comments”

Comments are closed.