# Getting Started

Course: [Angular](https://www.devtutorials.ai/learn/angular) · Section: Angular Fundamentals
Source: https://www.devtutorials.ai/learn/angular/fundamentals/getting-started

> What Angular is, why teams use it, how it differs from plain JavaScript, and how to install Node.js and the Angular CLI, create a project, read its files and run it.

## Introduction to Angular

Angular is a framework for building web applications quickly and efficiently.

A framework is a ready-made collection of tools and rules that simplifies development by handling many common and repetitive tasks.

Angular is free, open source, and maintained by Google. It uses TypeScript, which adds type safety to JavaScript and helps create more maintainable applications.

### Real-World Example

Consider a banking dashboard with a login page, an accounts list, a transfer form and live balance updates.

With plain JavaScript, your team writes its own routing, form validation, HTTP calls and DOM updates, and every developer may do it differently.

Angular provides all of these as built-in features with one standard structure, so the team spends its time on banking features instead of infrastructure code.

### Your First Angular App

Every Angular app is built from **components**. A component is one piece of the screen, such as a header, a menu or a product card.

Run the code below. The panel on the right shows the real app.

```angular runnable title="A complete Angular app in seven lines"
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `<h1>Hello, Angular!</h1>`,
})
export class App {}
```

The page shows **Hello, Angular!**

Here is what each part does:

- `@Component` marks the class as a component.
- `selector` is the name of the HTML tag for this component.
- `template` is the HTML the component shows on the screen.
- `export class App` is the class that holds the component's data and logic.

You can drag the bar between the code and the output to make either side wider. Press Ctrl+Enter (or ⌘+Enter on a Mac) to run the code from the keyboard.

## Why Angular?

Small pages are easy to build with plain JavaScript. Big apps are not.

A big app has many screens, many forms and many people working on it. Without clear rules, every developer builds things in a different way. The code becomes hard to read and hard to change.

Angular solves this with one clear way to build an app.

- **One structure for every app.** Any Angular developer can open your project and find their way around.
- **Everything included.** Routing, forms and calls to a server are all part of Angular. You do not need to pick many separate libraries.
- **TypeScript by default.** Many mistakes are found before the app runs.
- **Built for large teams.** Big companies use Angular for apps that live for many years.

## Features of Angular

These are the main features you will learn in this course.

- **Components.** Build the screen from small, reusable pieces.
- **Templates.** Write HTML with extra Angular syntax, such as `{{ name }}` to show a value.
- **Data binding.** When your data changes, the screen updates by itself.
- **Signals.** A simple way to store a value that the screen watches.
- **Dependency injection.** Share code, such as a data service, between components.
- **Routing.** Move between pages without reloading the browser.
- **Forms.** Build forms and check what the user types.
- **HTTP client.** Get data from a server and send data to it.
- **Angular CLI.** A command-line tool that creates, runs and builds your app.

The next example shows two of these features. Data binding shows a value in the page. The `@for` block repeats a line for every item in a list.

```angular runnable title="The screen is built from the data"
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <h2>{{ courseName }}</h2>
    <p>Lessons in this chapter:</p>
    <ul>
      @for (lesson of lessons; track lesson) {
        <li>{{ lesson }}</li>
      }
    </ul>
  `,
})
export class App {
  courseName = 'Angular Fundamentals';
  lessons = ['Getting Started', 'Components', 'Templates'];
}
```

Add a fourth lesson name to the `lessons` list and run the code again. A new line appears in the list. You did not write any new HTML.

## Angular vs Traditional JavaScript

In traditional JavaScript, you change the page yourself. You find an element, then you set its text.

In Angular, you change the data. Angular updates the page for you.

Both examples below build the same counter. Run each one and click its button.

<AngularCell mode="dom" title="Traditional JavaScript: you update the page by hand" code={`<p>Clicks: <span id="count">0</span></p>
<button id="add">Add one</button>

<script>
  let count = 0;
  const label = document.getElementById("count");
  document.getElementById("add").addEventListener("click", () => {
    count = count + 1;
    label.textContent = count;
  });
</script>`} />

```angular runnable title="Angular: you update the data, and the page follows"
import { Component, signal } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <p>Clicks: {{ count() }}</p>
    <button (click)="add()">Add one</button>
  `,
})
export class App {
  count = signal(0);

  add() {
    this.count.update((value) => value + 1);
  }
}
```

The Angular version never touches the page directly. It only changes `count`. The screen follows the data.

<figure className="ngc-fig">
<svg viewBox="0 0 640 210" role="img" aria-label="Traditional JavaScript: your code finds each element and changes the page. Angular: your code changes the data, and Angular updates the page.">
<defs><marker id="ngc-a1" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" className="ngc-arrowhead" /></marker></defs><text className="ngc-title c-orange" x="160" y="30" textAnchor="middle">Traditional JavaScript</text><text className="ngc-title c-red" x="480" y="30" textAnchor="middle">Angular</text><line className="ngc-divider" x1="320" y1="14" x2="320" y2="206" /><g className="ngc-node ngc-solid c-orange"><rect x="20" y="70" width="88" height="48" rx="9" /><text x="64.0" y="99" textAnchor="middle" style={{fontSize:"13px"}}>Your code</text></g><g className="ngc-node ngc-soft c-orange"><rect x="126" y="70" width="88" height="48" rx="9" /><text x="170.0" y="98" textAnchor="middle" style={{fontSize:"12px"}}>Find element</text></g><g className="ngc-node ngc-soft c-orange"><rect x="232" y="70" width="72" height="48" rx="9" /><text x="268.0" y="99" textAnchor="middle" style={{fontSize:"13px"}}>Page</text></g><line className="ngc-link ngc-flow c-orange" x1="108" y1="94" x2="124" y2="94" markerEnd="url(#ngc-a1)" /><line className="ngc-link ngc-flow c-orange" x1="214" y1="94" x2="230" y2="94" markerEnd="url(#ngc-a1)" /><text className="ngc-note" x="160" y="150" textAnchor="middle">You find every element and change it</text><text className="ngc-note" x="160" y="170" textAnchor="middle">by hand, again and again.</text><g className="ngc-node ngc-soft c-purple"><rect x="340" y="70" width="80" height="48" rx="9" /><text x="380.0" y="99" textAnchor="middle" style={{fontSize:"13px"}}>Code</text></g><g className="ngc-node ngc-solid c-red ngc-pulse"><rect x="445" y="70" width="80" height="48" rx="9" /><text x="485.0" y="99" textAnchor="middle" style={{fontSize:"14px"}}>Data</text></g><g className="ngc-node ngc-soft c-green"><rect x="550" y="70" width="80" height="48" rx="9" /><text x="590.0" y="99" textAnchor="middle" style={{fontSize:"13px"}}>Page</text></g><line className="ngc-link ngc-flow c-purple" x1="420" y1="94" x2="443" y2="94" markerEnd="url(#ngc-a1)" /><line className="ngc-link ngc-flow c-green" x1="525" y1="94" x2="548" y2="94" markerEnd="url(#ngc-a1)" /><text className="ngc-note" x="485" y="150" textAnchor="middle">You change the data.</text><text className="ngc-note" x="485" y="170" textAnchor="middle">Angular updates the page for you.</text>
</svg>
<figcaption>The same counter, two ways of thinking.</figcaption>
</figure>

| Point | Traditional JavaScript | Angular |
|---|---|---|
| Updating the page | You find each element and change it | You change the data, and Angular updates the page |
| Project structure | You decide it yourself | Angular gives one standard structure |
| Language | JavaScript | TypeScript |
| Moving between pages | The browser loads a new page | Angular swaps the view, with no reload |
| Tools | You choose and set up each tool | The Angular CLI sets everything up |
| Best for | Small pages and simple scripts | Large apps with many screens |

In Angular, you change the data. Angular changes the page. Keep this idea in mind for the whole course.

## Single Page Applications

A Single Page Application (SPA) loads one HTML page only once. After that, it changes the content inside that page as the user moves around.

A traditional website works differently. Every click on a link asks the server for a brand new page. The screen goes blank for a moment while the new page loads.

<figure className="ngc-fig">
<svg viewBox="0 0 640 224" role="img" aria-label="A traditional website reloads the whole page for every click. A Single Page Application keeps the menu and only swaps the content.">
<text className="ngc-title c-orange" x="160" y="26" textAnchor="middle">Traditional website</text><text className="ngc-title c-blue" x="480" y="26" textAnchor="middle">Single Page Application</text><rect className="ngc-win" x="40" y="44" width="240" height="150" rx="10" /><rect className="ngc-winbar" x="40" y="44" width="240" height="24" rx="10" /><circle className="ngc-dot c-red" cx="56" cy="56" r="4.5" /><circle className="ngc-dot c-yellow" cx="70" cy="56" r="4.5" /><circle className="ngc-dot c-green" cx="84" cy="56" r="4.5" /><g className="ngc-node ngc-soft c-orange ngc-old"><rect x="56" y="80" width="208" height="98" rx="9" /><text x="160.0" y="134" textAnchor="middle" style={{fontSize:"15px"}}>Page 1</text></g><g className="ngc-blink"><rect className="ngc-blank" x="41" y="69" width="238" height="124" /><text className="ngc-note" x="160" y="136" textAnchor="middle">Reloading the whole page…</text></g><rect className="ngc-win" x="360" y="44" width="240" height="150" rx="10" /><rect className="ngc-winbar" x="360" y="44" width="240" height="24" rx="10" /><circle className="ngc-dot c-red" cx="376" cy="56" r="4.5" /><circle className="ngc-dot c-yellow" cx="390" cy="56" r="4.5" /><circle className="ngc-dot c-green" cx="404" cy="56" r="4.5" /><g className="ngc-node ngc-solid c-blue"><rect x="372" y="76" width="216" height="26" rx="9" /><text x="480.0" y="93" textAnchor="middle" style={{fontSize:"12px"}}>Menu stays in place</text></g><g className="ngc-node ngc-soft c-blue ngc-swap ngc-s1"><rect x="372" y="110" width="216" height="72" rx="9" /><text x="480.0" y="152" textAnchor="middle" style={{fontSize:"16px"}}>Home</text></g><g className="ngc-node ngc-soft c-green ngc-swap ngc-s2"><rect x="372" y="110" width="216" height="72" rx="9" /><text x="480.0" y="152" textAnchor="middle" style={{fontSize:"16px"}}>Courses</text></g><g className="ngc-node ngc-soft c-purple ngc-swap ngc-s3"><rect x="372" y="110" width="216" height="72" rx="9" /><text x="480.0" y="152" textAnchor="middle" style={{fontSize:"16px"}}>Profile</text></g><text className="ngc-note" x="160" y="214" textAnchor="middle">Every click loads a new page</text><text className="ngc-note" x="480" y="214" textAnchor="middle">Only the content area changes</text>
</svg>
<figcaption>An SPA swaps the content, not the whole page.</figcaption>
</figure>

Angular apps are SPAs. Run the example and click the buttons. The view changes, but the page never reloads.

```angular runnable title="Three views, one page, no reload"
import { Component, signal } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <button (click)="view.set('Home')">Home</button>
    <button (click)="view.set('Courses')">Courses</button>
    <button (click)="view.set('Profile')">Profile</button>

    @if (view() === 'Home') {
      <h2>Home</h2>
      <p>Welcome back, Asha.</p>
    } @else if (view() === 'Courses') {
      <h2>Courses</h2>
      <p>You are learning Angular.</p>
    } @else {
      <h2>Profile</h2>
      <p>Asha, member since 2024.</p>
    }
  `,
})
export class App {
  view = signal('Home');
}
```

Real apps use the Angular **router** for this. The router also changes the address in the browser bar. You will learn it in a later chapter.

| Point | Traditional website | Single Page Application |
|---|---|---|
| Page loads | A new page for every click | One page, loaded once |
| Speed after the first load | Slower, because each page is downloaded | Faster, because only data is downloaded |
| Screen during a change | Goes blank for a moment | Changes smoothly |
| Examples | Many news and blog sites | Gmail, Google Maps, online dashboards |

## Angular Ecosystem Overview

The Angular ecosystem is the set of tools and libraries that work with Angular.

- **Angular CLI.** Creates, runs, tests and builds your app from the command line.
- **Angular Router.** Moves between pages inside an SPA.
- **Angular Forms.** Builds forms and checks the values a user types.
- **HttpClient.** Talks to a server to get or save data.
- **Angular Material.** Ready-made buttons, menus, tables and dialogs that follow Google's Material Design.
- **Angular DevTools.** A browser add-on that shows your components and their data while the app runs.
- **RxJS.** A library for handling data that arrives over time, such as server responses.
- **Angular SSR.** Builds the first page on the server, so the page appears faster and search engines can read it.

You do not need all of these on day one. This course adds them one at a time.

## Installing Node.js

Angular tools run on **Node.js**. Node.js runs JavaScript outside the browser, on your own computer.

Node.js also installs **npm**, the tool that downloads packages such as Angular.

### Step 1: Download Node.js

Go to [nodejs.org](https://nodejs.org) and download the **LTS** version. LTS means Long Term Support. It is the stable version that most people should use.

Angular 22 needs Node.js 22.22.3 or newer, or Node.js 24.15.0 or newer. The current LTS version works.

### Step 2: Install it

Run the installer and accept the default options.

### Step 3: Check the installation

Open a terminal. On Windows, use Command Prompt or PowerShell. On a Mac, use Terminal. Then type:

```bash
node -v
npm -v
```

Each command prints a version number. Your numbers may be newer.

```text
v24.15.0
11.6.2
```

If you see `command not found` or `is not recognized`, close the terminal, open a new one and try again. A new terminal reads the updated settings.

## Installing Angular CLI

The Angular CLI is a command-line tool. CLI stands for Command Line Interface. You type `ng` commands, and the CLI does the work.

Install it once, for your whole computer:

```bash
npm install -g @angular/cli
```

The `-g` option means "global". It makes the `ng` command available in every folder.

Check that it works:

```bash
ng version
```

The command prints the Angular CLI version, your Node.js version and your operating system.

On Windows, PowerShell may block the `ng` command with a message about "running scripts is disabled". Run this command once in PowerShell to allow it: `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned`. You can also use Command Prompt instead.

## Creating an Angular Application

Go to the folder where you keep your projects. Then run:

```bash
ng new my-first-app
```

The CLI asks a few questions, such as which stylesheet format to use. For now, press **Enter** to accept each default.

The CLI then does three things:

1. It creates a folder called `my-first-app`.
2. It writes all the starter files into that folder.
3. It downloads every package the app needs. This can take a minute or two.

If you want the defaults without any questions, add `--defaults`:

```bash
ng new my-first-app --defaults
```

## Understanding Project Structure

Open the `my-first-app` folder in your code editor. These are the files that `ng new` creates.

```text
my-first-app/
├── public/
│   └── favicon.ico
├── src/
│   ├── app/
│   │   ├── app.ts
│   │   ├── app.html
│   │   ├── app.css
│   │   ├── app.spec.ts
│   │   ├── app.config.ts
│   │   └── app.routes.ts
│   ├── index.html
│   ├── main.ts
│   └── styles.css
├── angular.json
├── package.json
├── tsconfig.json
├── tsconfig.app.json
└── tsconfig.spec.json
```

### The Files You Will Edit Most

| File | What it holds |
|---|---|
| `src/app/app.ts` | The main component class |
| `src/app/app.html` | The main component's template (its HTML) |
| `src/app/app.css` | Styles for the main component only |
| `src/app/app.routes.ts` | The list of pages for the router |
| `src/app/app.config.ts` | App-wide settings, such as the router |
| `src/styles.css` | Styles for the whole app |

### The Files That Start the App

| File | What it does |
|---|---|
| `src/index.html` | The single HTML page of the SPA. It contains the `<app-root>` tag. |
| `src/main.ts` | The first file that runs. It starts the main component. |

### The Project Files

| File | What it does |
|---|---|
| `package.json` | Lists the packages the app uses and the `npm` scripts |
| `angular.json` | Settings for the CLI, such as how to build the app |
| `tsconfig*.json` | Settings for the TypeScript compiler |
| `src/app/app.spec.ts` | A test for the main component |
| `public/` | Files copied as they are, such as images and the icon |
| `node_modules/` | The downloaded packages. Never edit this folder. |

Many older tutorials show files such as `app.component.ts` and `app.module.ts`. Those names come from older Angular versions. New projects use the shorter names shown above.

## Angular Architecture

Architecture means how the parts of an app fit together.

An Angular app is a **tree of components**. The main component, `App`, sits at the top. It contains other components, and they can contain more components.

<figure className="ngc-fig">
<svg viewBox="0 0 640 252" role="img" aria-label="A tree of components. App is at the top. It contains Header, CourseList and Footer. CourseList contains two CourseCard components. CourseService sends data to CourseList.">
<defs><marker id="ngc-a2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" className="ngc-arrowhead" /></marker></defs><line className="ngc-link" x1="320" y1="64" x2="130" y2="112" /><line className="ngc-link" x1="320" y1="64" x2="320" y2="112" /><line className="ngc-link" x1="320" y1="64" x2="510" y2="112" /><line className="ngc-link" x1="320" y1="156" x2="250" y2="198" /><line className="ngc-link" x1="320" y1="156" x2="390" y2="198" /><g className="ngc-node ngc-solid c-red ngc-pop ngc-p1"><rect x="260" y="20" width="120" height="44" rx="9" /><text x="320.0" y="48" textAnchor="middle" style={{fontSize:"16px"}}>App</text></g><g className="ngc-node ngc-soft c-blue ngc-pop ngc-p2"><rect x="70" y="112" width="120" height="44" rx="9" /><text x="130.0" y="139" textAnchor="middle" style={{fontSize:"15px"}}>Header</text></g><g className="ngc-node ngc-soft c-blue ngc-pop ngc-p2"><rect x="260" y="112" width="120" height="44" rx="9" /><text x="320.0" y="139" textAnchor="middle" style={{fontSize:"15px"}}>CourseList</text></g><g className="ngc-node ngc-soft c-blue ngc-pop ngc-p2"><rect x="450" y="112" width="120" height="44" rx="9" /><text x="510.0" y="139" textAnchor="middle" style={{fontSize:"15px"}}>Footer</text></g><g className="ngc-node ngc-soft c-purple ngc-pop ngc-p3"><rect x="190" y="198" width="120" height="44" rx="9" /><text x="250.0" y="225" textAnchor="middle" style={{fontSize:"15px"}}>CourseCard</text></g><g className="ngc-node ngc-soft c-purple ngc-pop ngc-p3"><rect x="330" y="198" width="120" height="44" rx="9" /><text x="390.0" y="225" textAnchor="middle" style={{fontSize:"15px"}}>CourseCard</text></g><g className="ngc-node ngc-solid c-green ngc-service"><rect x="490" y="198" width="130" height="44" rx="9" /><text x="555.0" y="225" textAnchor="middle" style={{fontSize:"14px"}}>CourseService</text></g><path className="ngc-link ngc-flow c-green" d="M520 198 C 490 170, 430 165, 382 150" markerEnd="url(#ngc-a2)" style={{fill:"none"}} /><circle className="ngc-packet c-green" r="5"><animateMotion dur="2.4s" repeatCount="indefinite" path="M520 198 C 490 170, 430 165, 382 150" /></circle>
</svg>
<figcaption>Components form a tree. App is the parent of Header, CourseList and Footer. A service sends data to the components that ask for it.</figcaption>
</figure>

### The Main Building Blocks

- **Component.** A piece of the screen. It has a class (the data and logic) and a template (the HTML).
- **Template.** The HTML that a component shows. It can display data and react to clicks.
- **Service.** A class that holds shared logic or data, such as the code that talks to a server.
- **Dependency injection.** The way a component asks Angular for a service. Angular creates the service and hands it over.
- **Router.** Decides which component to show for each address in the browser bar.

### See It Work

The example below has two components and one service. `App` shows a `CourseCard` for every course. Both get the course list from `CourseService`.

```angular runnable title="Two components share one service"
import { Component, Injectable, Input, inject } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class CourseService {
  getCourses() {
    return ['Angular', 'TypeScript', 'RxJS'];
  }
}

@Component({
  selector: 'course-card',
  template: `<li>📘 {{ title }}</li>`,
})
export class CourseCard {
  @Input() title = '';
}

@Component({
  selector: 'app-root',
  imports: [CourseCard],
  template: `
    <h2>My Courses ({{ courses.length }})</h2>
    <ul>
      @for (course of courses; track course) {
        <course-card [title]="course" />
      }
    </ul>
  `,
})
export class App {
  courses = inject(CourseService).getCourses();
}
```

Here is the flow, from the top:

1. `App` asks Angular for `CourseService` with `inject()`.
2. The service returns three course names.
3. The `@for` block creates one `CourseCard` for each name.
4. Each card receives its name through `[title]`.

A component must list the components it uses in `imports`. Remove `imports: [CourseCard]` and run the code. The course names disappear, and the console shows `NG0304: 'course-card' is not a known element`. Angular does not know what `<course-card>` is.

## Running an Angular Application

Go into the project folder, then start the development server:

```bash
cd my-first-app
ng serve
```

After a few seconds, the terminal shows a local address:

```text
➜  Local:   http://localhost:4200/
```

Open `http://localhost:4200` in your browser. You see the Angular welcome page.

`ng serve` keeps running and watches your files. When you save a change, the browser updates by itself. To stop the server, press **Ctrl+C** in the terminal.

You can also run `npm start`. It runs `ng serve` for you.

### What Happens When the App Starts

<figure className="ngc-fig">
<svg viewBox="0 0 640 112" role="img" aria-label="Start-up steps: 1 index.html loads, 2 main.ts runs, 3 bootstrapApplication starts Angular, 4 the App component appears inside app-root.">
<defs><marker id="ngc-a3" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" className="ngc-arrowhead" /></marker></defs><g className="ngc-step ngc-t1"><circle className="ngc-num c-orange" cx="75" cy="22" r="13" /><text className="ngc-numtxt" x="75" y="27" textAnchor="middle">1</text><g className="ngc-node ngc-soft c-orange"><rect x="10" y="44" width="130" height="56" rx="9" /><text x="75.0" y="77" textAnchor="middle" style={{fontSize:"14px"}}>index.html</text></g></g><line className="ngc-link ngc-flow c-slate" x1="142" y1="72" x2="168" y2="72" markerEnd="url(#ngc-a3)" /><g className="ngc-step ngc-t2"><circle className="ngc-num c-purple" cx="235" cy="22" r="13" /><text className="ngc-numtxt" x="235" y="27" textAnchor="middle">2</text><g className="ngc-node ngc-soft c-purple"><rect x="170" y="44" width="130" height="56" rx="9" /><text x="235.0" y="77" textAnchor="middle" style={{fontSize:"14px"}}>main.ts</text></g></g><line className="ngc-link ngc-flow c-slate" x1="302" y1="72" x2="328" y2="72" markerEnd="url(#ngc-a3)" /><g className="ngc-step ngc-t3"><circle className="ngc-num c-blue" cx="395" cy="22" r="13" /><text className="ngc-numtxt" x="395" y="27" textAnchor="middle">3</text><g className="ngc-node ngc-soft c-blue"><rect x="330" y="44" width="130" height="56" rx="9" /><text x="395.0" y="69" textAnchor="middle" style={{fontSize:"14px"}}>bootstrap</text><text className="ngc-sub" x="395.0" y="87" textAnchor="middle">Application()</text></g></g><line className="ngc-link ngc-flow c-slate" x1="462" y1="72" x2="488" y2="72" markerEnd="url(#ngc-a3)" /><g className="ngc-step ngc-t4"><circle className="ngc-num c-red" cx="555" cy="22" r="13" /><text className="ngc-numtxt" x="555" y="27" textAnchor="middle">4</text><g className="ngc-node ngc-solid c-red"><rect x="490" y="44" width="130" height="56" rx="9" /><text x="555.0" y="69" textAnchor="middle" style={{fontSize:"14px"}}>App on screen</text><text className="ngc-sub" x="555.0" y="87" textAnchor="middle">inside app-root</text></g></g>
</svg>
<figcaption>Each step lights up in the order it happens.</figcaption>
</figure>

1. The browser loads `index.html`. The page contains an empty `<app-root>` tag.
2. The browser runs the code from `main.ts`.
3. `main.ts` calls `bootstrapApplication(App, appConfig)`.
4. Angular finds the `<app-root>` tag and draws the `App` component inside it.

The next example uses the same `bootstrapApplication` call as a real `main.ts` file. Change the `title` and run it again.

```angular runnable title="Starting the app, the same way main.ts does"
import { Component, signal } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';

@Component({
  selector: 'app-root',
  template: `<h1>{{ title() }}</h1><p>The app started.</p>`,
})
export class App {
  title = signal('my-first-app');
}

bootstrapApplication(App)
  .catch((err) => console.error(err));
```

### Useful CLI Commands

| Command | What it does |
|---|---|
| `ng new my-app` | Creates a new project |
| `ng serve` | Runs the app at `http://localhost:4200` |
| `ng serve --open` | Runs the app and opens the browser |
| `ng generate component header` | Creates a new component |
| `ng build` | Builds the final files for a real server |
| `ng test` | Runs the tests |

## Common Mistakes

<div className="ngc-mistakes">

| Mistake | What you see | Fix |
|---|---|---|
| Node.js is too old | `requires a minimum Node.js version` | Install the latest LTS version of Node.js |
| `ng` used before installing the CLI | `ng: command not found` | Run `npm install -g @angular/cli`, then open a new terminal |
| PowerShell blocks `ng` | `running scripts is disabled` | Use Command Prompt, or run `Set-ExecutionPolicy` |
| `ng serve` run in the wrong folder | `outside a workspace` | Run `cd my-first-app` first |
| Port 4200 already in use | `Port 4200 is already in use` | Stop the other server, or use `ng serve --port 4300` |
| Editing files in `node_modules` | Changes disappear after the next install | Edit only the files inside `src/` |
| Child component missing from `imports` | `NG0304: ... is not a known element` | Add the child to the parent's `imports` list |
| Changing the page with `document` code | The page and the data stop matching | Change the data, and let Angular update the page |

</div>

## Check Yourself

## Exercises

## What to Remember

- Angular is a framework for building large web apps from components.
- In Angular, you change the data, and Angular updates the page.
- Install Node.js, then the Angular CLI. Create an app with `ng new` and run it with `ng serve`.

Next: **Components**, how to build your own pieces of the screen.
