Show Menu
Cheatography

angular cli Cheat Sheet by

Creating Projects

ng new <pr­oje­ct-­nam­e> [options]
Creates a new angular project in the current directory
ng init <pr­oje­ct-­nam­e> [options]
Creates a new angular project in the current folder
Options:
--dry-run (Outputs results but does not create the project)
--verbose (Output all the things­!!!1!)
--skip-npm (Does not run npm commands after project creation)
--skip-git (Does not initialize the repo as a git repo
--dire­ctory (Specify the parent directory when creating the project)

Examples:
ng new MyProject

ng new MyProject --dire­ctory c:/Rep­os/­Angular

ng init MyProject --skip-git

Generating Code

ng generate <ty­pe> [options]
Generates code files in your project. Generated files get their own direct­ories by default
component <pa­th/­nam­e>
Generates a new component at the specified path with the specified name
directive <pa­th/­nam­e>
Generates a new directive at the specified path with the specified name
route <ro­ute­/ro­ute­-co­mpo­nen­t>
Generates a route to the named component. The name should be the route used in RouteC­onfig
pipe <pa­th/­nam­e>
Generates a pipe with the specified name at the specified path
service <pa­th/­nam­e>
Generates a new service at the specified path with the specified name
Options:
--flat (Do not create new files in their own directory)
--rout­e=<­rou­te> (Specify the parent route when generating components and routes)
--skip­-ro­ute­r-g­ene­ration (Do not generate the route config for the parent when generating routes)
--default (Specify the route should be the default route)
--lazy (Specify the route is lazy and default to true)

Examples:
ng generate component MyComp­onent --flat

ng generate service app/se­rvi­ces­/My­Service

Workflow Tasks

ng doc <ke­ywo­rd>
Searches the keyword in the Angular docs online
ng format
Formats the project code using clang-­format
ng test [options]
Run project unit tests using karma
ng e2e
Runs all project end to end tests using protractor
ng lint
Runs codelyzer linter on your project
Options:
--watch (Keep unit tests alive and running)

Examples:
ng test --watch

ng lint
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.