Getting Started!
Learn how to use the Angular CLI to generate an Angular application.
Create the project
Section titled “Create the project”Angular provides a Command Line Interface (CLI) to generate a new Angular application, manage the project, and run the application locally.
Instructions
Section titled “Instructions”-
Open a terminal and run the following command to install the Angular CLI:
Admin modeYou might need to run the command with administrator privileges, depending on your operating system. Either run the command with
sudoprefix on Linux or macOS, or open the terminal as an administrator on Windows.Terminal window npm install -g @angular/cli@latestNoteThe
-gflag installs the Angular CLI globally, allowing you to use thengcommand from any directory. -
Open a terminal and run the following command to create an Angular application:
Terminal window ng new angular-introduction-course --style=tailwind --ssr=false --skip-tests=trueNoteThe command includes some options to facilitate the learning process. Learn more about the options in
Angular CLI Options
.
-
Open your IDE.
-
For Visual Studio Code: Click on the
Filemenu and selectOpen Folder.
For Webstorm: Click on theFilemenu and selectOpen.... -
Navigate to the
angular-introduction-coursefolder and click theSelect Folderbutton for Visual Studio Code and theOpenbutton for Webstorm. -
Open your IDE’s terminal.
-
Type the following command to start the application:
Terminal window ng serveAngular AnalyticsBy running a project for the first time, Angular will prompt you to allow to share pseudonymous usage data with the Angular team. You can choose to allow or disallow this.
-
Open your browser and navigate to
http://localhost:4200. -
You should see the following default base page:
Welcome to angular-introduction-course!
Hot Reloading
Section titled “Hot Reloading”Hot reloading is a feature that allows you to see the changes you make to your code without having to manually refresh the page.
-
Locate and open the
app.htmlfile in thesrc/appdirectory.Terminal window src└─ app└─ app.html -
Locate the placeholder (which is wrapped in HTML comment tags) in the
app.htmlfile and replace the template content with following:app.html <h1>Welcome to {{title()}}!</h1> -
In the file
app.ts, locate theimportsarray and remove theRouterOutletimport:app.ts import { RouterOutlet } from '@angular/router';app.ts @Component({// ...imports: [RouterOutlet],})export class App {// ...} -
Return to your browser to see the following page:
Task Manager