Angular CLI is a command line tool that can aid in creating new Angular projects from scratch or adding various elements to an existing Angular application. you’re not required to use Angular CLI to develop an Angular application, but its many features can highly improve the quality of your code and save you a lot of time along the way.
In order to install Angular CLI, the following should be installed in the development environment:
– Installing Angular CLI
$ npm install -g @angular/cli
– Creating a New Angular Application
ng init: create a new application in the current directory
ng new: create a new directory and run
ng initinside the new directory.
$ ng new my-app
– Run Application
Change to the
my-app directory and run the following:
$ ng serve
Then open a browser and point it to
-Create A Class (ts file)
To create a new class, run the following:
$ ng g class my-class-a
This will create a file called my-class-a.ts under the src/app directory.
– Create A Component
To create a new component, run the following:
$ ng g component my-component-a
- create a directory called
- generate four files