Angular Setup
Installing the Angular CLI
You can use Angular CLI to create projects, generate application and library
code, and perform a variety of ongoing development tasks such as testing,
bundling, and deployment.
Install the Angular CLI globally.
To install the CLI using npm, open a terminal/console window and run the
following command.
npm install –g @angular/cli
Create a workspace and initial application
You develop apps in the context of an Angular workspace.
To create a new workspace and initial starter app:
- Run the CLI command ng new and provide the name filename as my-app, as
shown below
ng new my-app
- The ng new command prompts you for the information about features to
include
in the initial app. Accept the defaults by pressing the Enter or Return key.
The Angular CLI installs the necessary Angular npm packages and other
dependencies. This can take a few minutes. The CLI creates a new workspaces and
a simple Welcome app, ready to run.
Run the application
The Angular CLI includes a server, so that you can build and serve your app
locally.
- Navigate to the workspace folder, such as my-app.
- Run the following commands:
cd my-app
ng serve --open
The ng serve command launches the server, watches your files, and rebuilds the
app as you make changes to those files.
The --open
or -o
just Option automatically opens your
browser to http://localhost:4200/.