Angular CLI Commands

C:\Users\amit.maddheshiya\AppData\Roaming

npm -v

node -v

  1. Install Angular globally

npm install -g @angular/cli

or 

npm i -g @angular/cli 

ng -v

  1. ng new MyFirstApp

or

ng new MySecondApp –dry-run

or 

ng new MyFirstApp –skip-install; npm install

  1. cd MyFirstApp
  1. code .
  1. ng serve –open //to start server and open defualt browser
  1. ng e2e //to run end to end test cases
  1. Help document of angular

ng –help

or

ng –help | clip

or

ng –help >MyTextDoc.txt

or

ng –help >MyWordDoc.doc

  1. ng generate component abc | ng g c abc
  2. ng generate component abc/xyz
  3. ng g c pqr –flat
  4. ng g c abc/xyz –flat

12  ng generate component abc/xyz -d

  1. ng generate component abc/xyz –dry-run
  2. ng g c abc/xyz -it -is –spec=false -d
  3. ng generate service employee
  4. ng g s student -d –spec=false 
  5. ng g s student -d –spec=false –flat=false  –If you want a folder of it’s own for a service 
  6. ng g m students -d -m=app.module
  7. ng g m students -m=app.module –spec=false –flat=true
  8. ng g d directiveName –skip-import -d

    or

    ng g d directiveName -m=app.module -d

  1. ng g class employee/employee –spec=true 

or

    ng g cl employee/employee –spec=true 

  1. ng g interface employee/employee –spec=true 

or

    ng g i employee/employee –spec=true 

  1. ng g enum employee/employee –spec=true 

or

    ng g e employee/employee –spec=true 

  1. ng lint #to check code symantic issues
  2. ng lint –fix
  3. ng lint –help
  1. ng new RoutingDemo –routing 

ng g c HomeComponent

ng g c EmployeesComponent

ng g c PageNotFoundComponent

import { HomeComponent } from ‘./home/home.component’;

import { EmployeesComponent } from ‘./employees/employees.component’;

import { PageNotFoundComponent } from ‘./page-not-found/page-not-found.component’;

const routes: Routes = [

  { path: ‘home’, component: HomeComponent },

  { path: ’employees’, component: EmployeesComponent },

  { path: ”, redirectTo: ‘/home’, pathMatch: ‘full’ },

  { path: ‘**’, component: PageNotFoundComponent }

];

<div style=”padding:5px”>

<ul class=”nav nav-tabs”>

        <li routerLinkActive=”active”>

            <a routerLink=”home”>Home</a>

        </li>

        <li routerLinkActive=”active”>

            <a routerLink=”employees”>Employees</a>

        </li>

</ul>

<br/>

<router-outlet></router-outlet>

</div>

npm install bootstrap@3 –save 

“styles”: [

  “node_modules/bootstrap/dist/css/bootstrap.min.css”,

  “styles.css”

]

  1. ng serve –help
  2. ng build or ng build –dev
  3. ng build –prod
  4. ng build –dev -sm false    or  ng build –prod -sm true
  5. ng build –dev -ec true

=====================================================

for full stack product

npm i npm (to update npm)

npm run build

Creating new angular app

ng new product-mart –routing –style scss –prefix pm –skip-install –dry-run

with routing module wi sass as defualt style with pm as the prefix to component and directives with skip install so it just create

the folder structures with dry dry run so that it will just create in memory and diplay it in the console

ng add @angular/material

ng g c home

ng g m products –routing

ng g c products/products -m products/products.module

ng g s product-data –dry-run

npm i express –save

npm run lint

ng lint –fix

ng g c login

ng g s auth

ng g c register

npm i -S dotenv body-parser cors helmet morgan express-async-handler

npm i -D concurrently nodemon

npm i -S mongoose

npm i -S bcrypt

npm i -S passport passport-jwt passport-local jsonwebtoken

ng g s tokenStorage

ng g s authHeaderInterceptor

npm i -S http-errors