Saturday, May 23, 2020

Angular CLI commands

In this article I am going explain the all Angular CLI commands.

 The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications. You can use the tool directly in a command shell, or indirectly through an interactive UI such as Angular Console.

Follow the below given command as per your requirement :

Install Angular CLI

npm install -g @angular/cli


Angular command help

ng help


Create Angular Application

ng new BlogApp


Run Angular Application

ng serve --open


Run Angular Application with different port number

ng serve --port 8081


Build Angular application

ng build


Build Angular Application for Production

ng build --prod


Add component

ng g c ArticleList


Add Class

ng g class Article


Add Model Class

ng g class Article --type=model


Add Service

ng g s ArticleService


Add Interface

ng g i Article


Add Directive

ng g directive TitleCase


Add Module

ng g module Article



ng g pipe App-pipe


NOTE : If you have noticed that when we generated component, model etc. the CLI created .spec.ts file for every component, model, service. This file is not needed, so you can skip this file when generating component, models or can delete.

To skip this file use below given command:

ng g c ArticleList --skip-tests


No comments:

Post a Comment