CLI Commands
Installing Angular CLI
npm install -g @angular/cli
Help
ng help
Check version
ng version
Create, build, and serve a new, basic Angular project cli command
ng new my-first-project
cd my-first-project
ng serve
Generating new application
ng new app-name
Create new app without installing cli
npm init @angular app-name
Component
ng g c component-name
ng generate component component-name
Adding External libraries
ng add
Build
ng build
Running project
ng serve
Run project on particular port
ng serve --port=portname
// example
ng serve --port=3000
Run project and open the url in default browser
ng serve --open
Update
ng update
Directive
ng generate directive component-name
ng g directive component-name
Module
ng generate module module-name
ng g m module-name
Service
ng generate service component-name
ng g service component-name
Routing Module
ng g module module-name --routing
ng g m module-name --routing
Component with module, routing module
ng generate module component-name --route component-name --module app.module
Pipe
ng g pipe pipe-name
Enum
ng g enum some-enum
Class
ng g cl my-class
Interface
ng g interface my-interface
Guard
ng g guard guard-name
Multiple Projects in one Angular App
ng generate application sub-app-name
ng new app-name --create-application=false
Generate environments
ng generate environments