Skip to content

Instantly share code, notes, and snippets.

@bipon68
Last active March 17, 2020 03:42
Show Gist options
  • Save bipon68/835e00873c9b4ebe2d366498bc5950b3 to your computer and use it in GitHub Desktop.
Save bipon68/835e00873c9b4ebe2d366498bc5950b3 to your computer and use it in GitHub Desktop.
angular-cli-command
#Angular CLI overview
- A command line interface for Angular
Purpose:
- Build an Angular application
- Generate Angular files
- Execute the application
- Run unit and end to end tests
- Prepare the application for deployment
# Angular CLI Commands
ng help - Displasy commands and flags
ng new - Creates new Angular application
ng serve - Launches a server
ng generate - Generates file from blueprint
ng test - Runs unit tests usning Karma
ng e2e - Runs end to end tests using Protractor
ng build - Compiles into an output directory
# Angular CLI Generate Code
class - ng g cl
component - ng g c
directive - ng g d
enum - ng g e
guard - ng g g
interface - ng g i
module - ng g m
pipe - ng g p
service - ng g s
#Common App Generation Flags in Angular
ng new my-app --style scss (Styles should use SASS)
ng new my-app --prefix ma (Set the default selector prefix)
ng new my-app --skip-git (Don't add the project to git)
ng new my-app --skip-tests (Don't generate spec files)
ng new my-app --routing (Add a default routing module)
ng new --help
ng serve --help
#Many flags can be combined
ng new my-app --routing --style scss --prefix ma
- add routing
- define your styles
- set your prefix
#Common ways to Genenerate Component
- ng generate component pet (shortcut - ng g c pet)
- ng generate component pet -inline-template --inline-style (shortcut - ng g c pet -t -s)
- ng g c pet -st --flat --prefix my
- ng g d search-box2 --flat false (Add a folder for search-box2)
ng g d search-box2 --flat false -d (-d means no changes in project directory. Just see component creation success or not)
#NgModules and Routing
- ng g module admin (Generate admin.module.ts)
- ng g m sales --routing (sales.module.ts & sales-routing.module.ts)
#ng serve --port 8626
# material added
ng add @angular/material
ng g @angular/material:material-nav --name nav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment