Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Angular 2 - Start new project with angular-cli
# install angular cli
sudo npm install -g angular cli
# init new application
ng new app_name --routing
cd app_name
ng init app_name
# serve your application
ng serve
# or
ng serve --host --port 4201
# or
npm start
# create a new component
ng generate component hello
ng g module hello --routing
# other commands
Component: ng g component my-new-component
Directive: ng g directive my-new-directive
Pipe: ng g pipe my-new-pipe
Service: ng g service my-new-service
Class: ng g class my-new-class
Guard: ng g guard my-new-guard
Interface: ng g interface my-new-interface
Enum: ng g enum my-new-enum
Module: ng g module my-module
ng build
ng test: Run unit tests with karma
ng e2e: Run end-to-end tests with protractor
ng get: Gets values for project
ng set: Sets values for project
ng github-pages:deploy: Build the app for production, setup GitHub repo, and publish
ng lint: Run codelyzer to analyze code
ng format
ng doc
ng version: Get the version of the CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment