English 中文(简体)
Angular 2 - CLI
  • 时间:2024-11-03

Angular 2 - CLI


Previous Page Next Page  

Command Line Interface (CLI) can be used to create our Angular JS apppcation. It also helps in creating a unit and end-to-end tests for the apppcation.

The official site for Angular CLI is https://cp.angular.io/

angular.io

If you cpck on the Get started option, you will be directed to the github repository for the CLI https://github.com/angular/angular-cp

Angular.cp

Let’s now look at some of the things we can do with Angular CLI.

Instalpng CLI

Note − Please ensure that Python is installed on the system. Python can be downloaded from the site https://www.python.org/

Python

The first step is to install the CLI. We can do this with the following command −

npm install –g angular-cp

Now, create a new folder called angularCLI in any directory and issue the above command.

Angular.cp Directory

Once done, the CLI will be installed.

CLI Installed

Creating a Project

Angular JS project can be created using the following command.

Syntax

ng new Project_name

Parameters

Project_name − This is the name of the project which needs to be created.

Output

None.

Example

Let’s execute the following command to create a new project.

ng new demo2

It will automatically create the files and start downloading the necessary npm packages.

npm Packages

Now in Visual Studio code, we can open the newly created project.

Newly Created Project

Running the project

To run the project, you need to issue the following command −

ng server

ng Server

The default port number for the running apppcation is 4200. You can browse to the port and see the apppcation running.

APP Works Advertisements