Appendix: Angular

Learn how to set up an Angular development environment on a local machine.

We'll cover the following

Angular setup

Angular uses a command-line tool known as the Angular CLI to facilitate the creation of Angular applications and components. The Angular CLI can be installed using npm as follows:

npm install -g @angular/cli

Here, we install the package @angular/cli globally using npm. Once installed, the Angular CLI provides a utility named ng, which can be used to create an Angular application as follows:

ng new angular-app

Here, we invoke the Angular CLI and specify that we wish to create a new Angular application named angular-app.

The Angular CLI will ask a few questions when creating an application, such as whether we would like to enforce strict type checking, whether to include Angular routing and which stylesheet format we would like to use.

Once the Angular CLI has been completed, we can switch to the newly created angular-app directory and start up a development server as follows:

cd angular-app
npm start

Here, we call the start script that Angular has included in the package.json file. This script will invoke the Angular CLI with the command ng serve, which will compile our application, start a local web server, and additionally run the compiler in watch mode. By default, the web server will run on port 4200, which we can open in our browser as localhost:4200.

It will look like this:

Get hands-on with 1200+ tech skills courses.