Chapter 1: Introduction & First Component

Introduction & First Component very slowly, very human-style — like a patient teacher who really wants you to feel comfortable with Angular right from the start.

No rushing, lots of small examples, explanations why things are done this way in 2026 (Angular v21 era), and we’ll build everything step by step.

1. What actually is Angular? (2026 honest explanation)

Imagine you’re building a house.

  • Plain HTML + CSS + JavaScript = you build everything brick by brick, manually. Fine for small shed, painful for a 10-floor building.
  • React / Vue = you get good Lego blocks, but you still decide almost everything yourself (routing? forms? state? testing? — you pick libraries).
  • Angular = full ready-made construction company. They give you:
    • Pre-designed strong Lego blocks (components)
    • Automatic delivery system for data to screen (binding + signals)
    • Built-in routing, forms, HTTP client, animations, testing tools, CLI for scaffolding
    • Strong typing with TypeScript (catches mistakes early)
    • Opinionated structure → your 10-person team writes code that looks similar

In January 2026 → Angular v21 is current stable version (released late 2025). It focuses heavily on:

  • Signals → new super-easy reactivity (much simpler than old RxJS for 80% of cases)
  • Standalone components → no more NgModule boilerplate for most apps
  • @if @for @switch → cleaner template control flow (no more *ngIf hacks)
  • AI-friendly → better editor integrations & prompt patterns for GitHub Copilot / Cursor etc.

Angular today is fast, modern, great for medium-to-large apps (dashboards, admin panels, e-commerce backoffices, SaaS tools), excellent editor support, long-term support.

Okay — enough theory. Let’s create something right now.

2. Creating your very first standalone component (hands-on)

Step 0: Make sure you have tools (5 minutes)

You need:

  • Node.js 20+ or 22+ or 24+ (v21 works great with any of these)
  • npm (comes with Node)

Open terminal / command prompt:

Bash

Install Angular CLI globally (only once):

Bash

Now create fresh project (Angular v21 style — standalone by default):

Bash

→ Browser opens http://localhost:4200 You should see default welcome screen.

This project already contains your first component — the root one.

Step 1: Open & understand app.component.ts (your first component)

Location: src/app/app.component.ts

TypeScript

Three main parts of almost every component:

  1. @Component decorator → metadata (name, template, styles…)
  2. class → your logic + data (like Java class or TS class)
  3. template (HTML file) → what user actually sees

Step 2: Change something simple — interpolation magic

Open src/app/app.component.html Delete most of it and write only this:

HTML

Now go to app.component.ts and add:

TypeScript

Save both files → browser auto-updates → you see:

Hello from Webliance in Airoli! Welcome to my first Angular app → Webliance Angular Adventure Today’s date magic: Tuesday, January 27, 2026 (or whatever today is)

{{ title }} = interpolation. Angular takes value from component class → puts it into HTML live.

→ | date:’fullDate’ = pipe (built-in formatter)

3. Templates, interpolation {{ }}, and basic data binding (deeper examples)

A. Interpolation {{ }} — showing values

Anything inside {{ … }} is TypeScript expression evaluated and shown as text.

More examples — replace content of .html file:

HTML

Matching .ts:

TypeScript

→ Everything updates live when you change values.

B. Property binding [ ] — controlling attributes

Interpolation only works for text content. For attributes (src, href, class, style, disabled…) use square brackets [ ]

Example — let’s add image & button:

Add to .ts:

TypeScript

Add to .html:

HTML

CSS in app.component.css (just for fun):

CSS

→ [src]=”photo” → Angular sets src attribute to value of photo → [disabled]=”isButtonDisabled” → button disabled when true → You can bind almost any property this way

C. Quick recap table (very beginner friendly)

What do you want? Syntax you write Meaning / when to use
Show text from variable {{ variable }} Inside tag content (p, span, h1…)
Set attribute (src, href…) [src]=”imageUrl” Images, links, ids, custom attrs
Toggle class [class.active]=”isActive” Add/remove CSS class conditionally
Set inline style [style.color]=”‘red'” Change color, font-size, etc. directly
Disable/enable element [disabled]=”!formValid” Buttons, inputs during loading/validation

Tiny practice challenge for today (5–10 min)

  1. Add these properties to your AppComponent class:
TypeScript
  1. Show them in HTML with interpolation + some calculation:
HTML
  1. Bonus: Add a button that changes mood
HTML

And in .ts:

TypeScript

(Notice (click) → that’s event binding — we’ll go deeper next time)

Save → play → see live changes.

You did it! You now understand:

  • What Angular is for
  • Standalone component structure
  • Interpolation {{ }} for text
  • Property binding [ ] for attributes

Next time (if you want) → inputs (passing data to child components), @if / @for control flow, and little more fun events.

How did this feel? Any part confusing? Want to fix something / add picture example / go slower on one topic? Just tell me — I’m right here 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *