Hello World in Angular - Make First Change in Code
Focus: Build your first Angular App and understand how the “Hello World” works.
Creating the Angular Project
- Start by opening the command prompt or Terminal.
- Use Angular CLI to generate a new Angular application:
ng new hello-angular
Accept the defaults or choose CSS/SCSS as per your preference.
Running the Angular App
- Navigate to the project folder:
cd hello-angular
Then start the development server:
ng serve --open
Browser opens at http://localhost:4200 — showing the default Angular welcome page.
Understanding the Angular App Structure
- The instructor explains important folders:
- src/ — where all app code lives
- app/ — where components are defined
- main.ts — application entry file
- index.html — default HTML loaded in the browser
- (common Angular real structure explained in most Angular videos)
Modifying the “Hello World” Message
- Open
src/app/app.component.html - Replace default Angular template code with:
<h1>Hello Angular World!</h1>
Save and check the browser — the message updates automatically thanks to Angular’s live reload.
Explanation of Components
- The instructor describes what a component is:
- A component has 3 pieces:
- HTML template
- CSS styles
- TypeScript logic
- The
app.component.tsfile connects them.
Changing the Title from TS File
- Inside
app.component.ts, the instructor shows how to change thetitleproperty:
export class AppComponent {
title = 'Hello Angular World!';
}
Then reflects it in the HTML using interpolation:
<h2>{{ title }}</h2>
Browser shows dynamic text.
Auto-Reload Feature
- Angular CLI provides hot reload by default.
- Any file change gets reflected instantly in the browser without manual reload.