Loading, please wait...



Understanding the Angular CLI

Oct 17, 2019 Angular CLI, CLI, 827 Views
In this article we will learn about Angular CLI. It is very common word for any version of Angular. Only few people are knowing about it.So the main aim of writing this article is that, what is it and why use it according to my knowledge.

In this article we will learn about Angular CLI. It is very common word for any version of Angular. Many people are use it but only few people are knowing its's importance. So the main aim of writing this article is that, what is it and why use it according to my knowledge.

What are the New features in Angular 8

Exploring Angular Decorators

Exploring @Input() and @Output() Decorator in Angular

Angular Interview Questions with Answers

Node Package Manager Tutorial Step by Step

Let's start

Angular CLI:

CLI acronym for Command Line Interface, and it command line tool which help us to create an angular
application very easy and simple way. It makes our work very easier. It perform many tasks likewise create components,
directives, pipes, services,classes, interfaces, enums etc. Not ony create these things even install and update every in angular.

It is done our task very quickly.

Why we use it:

If you have worked or collect knowledge of Angular, then you already familiar with angular manual setting of an application. And If you have
start your project from scratch the you know well about their hardwork and consume time.

Here just I want to remember your hardwork and time consumption. They are as given below.

1. Create a folder for specific application and add many configuration files.
2. Install each and every packges which is required for your application using NPM.
3. Create a component for an application which is root component and every application should have atleast one component.
4. Create AppModule as every angular application. And every application should have atleast one module.
5. Many more things...


As you can see above or you remembered your past. if we want to create application in angualr then you have
use our extra effort and spend more time. For create a root component you have to create atleast three files manually like
html,css and ts. First create your html file which is app.component.html and second file app.component.css and last one is that app.component.ts
file.

I mean it was not draw back becuase that time it was good. For the time being it have changed.

Then, to overcome our effort Angular CLI comes on picture. Let's try to understand how it overcome our problem quickly not Zero(0) but veryless.
Now a day we do not need to extra effort we have to remember commands and then
perform our task which I want. And it is done by Angular CLI.

Let's real world example:


1. For the installation of angular it play vert vital role.
2. Create any angular application just type command and it takes few seconds.
3. Create components, directives, pipes, services,classes etc. by using commands

How to install Angular CLI

Major versions of Angular CLI follow the supported major version of Angular, but minor versions can be released separately.

Syntax:

 

npm install -g @angular/cli

see above syntax -g is not necessory 

I will explain most of commands but right now few commands are given there which is very important.

Create an appication:

To create a new angular application use below command.

Syntax:

ng new applicationName

 Create Component:

To create a component use below command.

Syntax:

ng generate component <name>
ng g component <name>

 Create Directive:

It is used to create a new generic directive definition in the given or default project use below command.

Syntax:

ng generate directive <name>
ng g directive <name>


Create module:

It is used to create a new generic NgModule definition use below command.

Syntax:

ng generate module <name> 
ng g module <name> 


Create  enum:

It is used to create a new, generic enum definition use below command.

Syntax:

ng generate enum <name> 
ng g enum <name> 


Not only for creating these parts, aparts from this it is  used to create, build, execute, open, an application in browser.

Conclusion: There is no doubt Angular CLI, will very helpfull for us improve our productivity and time saving , work makes easy. Remaining commands we will see on next article.