Angular · Beginner Tutorial
Angular Basics Explained in Plain Simple Language
Quick summary — Angular basics in plain language
Angular is a framework for building web applications. Think of it as a toolbox that gives you everything you need — components, templates, data binding, directives, services, and routing — to build fast, modern apps.
In this guide you will learn:
- Components — the building blocks of an Angular app.
- Templates & Data Binding — how the HTML talks to the code.
- Directives — instructions that change how the page behaves.
- Services & Dependency Injection — shared logic and data.
- Routing — navigating between pages.
SECTION 01What is Angular?
Angular is a JavaScript framework (written in TypeScript) for building web applications. It gives you a structured way to build apps — like LEGO blocks for the web. Instead of writing everything from scratch, you use Angular's building blocks to build faster and cleaner.
| Concept | Plain English | Real-World Analogy | Why It Matters |
|---|---|---|---|
| Framework | A toolbox with rules and helpers | Like a pre-built kitchen | You build faster |
| TypeScript | JavaScript with extra safety | Like spell-check for code | Fewer bugs |
| SPA | Single Page Application | Like a mobile app in the browser | Fast, smooth experience |
| CLI | Command Line Interface | Like a remote control for your project | Create files in seconds |
# Install Angular CLI globally
npm install -g @angular/cli
# Create a new project
ng new my-app
# Go into the project
cd my-app
# Start the development server
ng serve
# Open http://localhost:4200
// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `Hello, {{ name }}!
`
})
export class AppComponent {
name = 'Angular';
}
SECTION 02Components — The Building Blocks
A component is the basic building block of an Angular app. It's a piece of the UI — like a button, a card, or a whole page. Each component has two parts:
- Class — the logic (data and functions) written in TypeScript.
- Template — the HTML that tells Angular what to show.
| Week | Concept | What You Do | Goal |
|---|---|---|---|
| Week 1 | Create Components | Create a header component and a footer component | Understand @Component |
| Week 2 | Reuse Components | Use one component multiple times in the app | Learn how components nest |
| Week 3 | Component Inputs | Pass data into a component using @Input | Make components reusable |
| Week 4 | Component Outputs | Emit events from a component using @Output | Make components interactive |
import { Component } from '@angular/core';
@Component({
selector: 'app-card',
template: `
<div class="card">
<h2>{{ title }}</h2>
<p>{{ body }}</p>
</div>
`,
styles: [`
.card { border: 1px solid #ddd; padding: 16px; border-radius: 8px; }
`]
})
export class CardComponent {
title = 'My Card';
body = 'This is a simple card component.';
}
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-button',
template: `<button (click)="handleClick()">{{ label }}</button>`
})
export class ButtonComponent {
@Input() label = 'Click me';
@Output() clicked = new EventEmitter<void>();
handleClick() {
this.clicked.emit();
}
}
SECTION 03Templates & Data Binding
Templates are HTML files that tell Angular what to show. Data binding is how the template and the component class talk to each other. There are four kinds:
| Type | Syntax | Direction | Example |
|---|---|---|---|
| Interpolation | {{ value }} | Class → Template | {{ name }} |
| Property Binding | [property]="value" | Class → Template | [src]="imageUrl" |
| Event Binding | (event)="handler()" | Template → Class | (click)="save()" |
| Two-Way Binding | [(ngModel)]="name" | Both ways | [(ngModel)]="username" |
<h1>Hello, {{ name }}!</h1>
<p>You are {{ age }} years old.</p>
// In the component:
export class AppComponent {
name = 'Angular Learner';
age = 25;
}
<input [(ngModel)]="username" placeholder="Enter your name">
<p>Hello, {{ username }}!</p>
// In the component:
export class AppComponent {
username = '';
}
<button (click)="increment()">Click me</button>
<p>Count: {{ count }}</p>
// In the component:
export class AppComponent {
count = 0;
increment() {
this.count++;
}
}
SECTION 04Directives
Directives are instructions that tell Angular to do something with the DOM — like show or hide an element, repeat it, or style it. There are three types:
- Component directives — the components you already use.
- Structural directives — change the layout (ngIf, ngFor, ngSwitch).
- Attribute directives — change appearance or behavior (ngClass, ngStyle).
<div *ngIf="isLoggedIn; else loggedOut">
Welcome back!
</div>
<ng-template #loggedOut>
Please log in.
</ng-template>
<ul>
<li *ngFor="let item of items; let i = index">
{{ i + 1 }}. {{ item }}
</li>
</ul>
// In the component:
items = ['Angular', 'React', 'Vue'];
<!-- ngClass -->
<div [ngClass]="{ 'active': isActive, 'disabled': isDisabled }">
Styled box
</div>
<!-- ngStyle -->
<p [ngStyle]="{ color: textColor, fontSize: fontSize + 'px' }">
Hello
</p>
SECTION 05Services & Dependency Injection
Services are classes that hold shared logic and data. They are used to share code between components — like fetching data from an API, logging, or authentication. Dependency injection (DI) is how Angular gives a component a service it needs.
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService {
private items = ['Angular', 'React', 'Vue'];
getItems() {
return this.items;
}
addItem(item: string) {
this.items.push(item);
}
}
import { Component } from '@angular/core';
import { DataService } from './data.service';
@Component({
selector: 'app-item-list',
template: `
<ul>
<li *ngFor="let item of items">{{ item }}</li>
</ul>
<button (click)="add()">Add AngularJS</button>
`
})
export class ItemListComponent {
items: string[] = [];
constructor(private dataService: DataService) {
this.items = dataService.getItems();
}
add() {
this.dataService.addItem('AngularJS');
this.items = this.dataService.getItems();
}
}
SECTION 06Routing
Routing lets you navigate between different pages in a single-page app. Angular's Router maps URLs to components, so when you click a link, the URL changes and a different component is shown — without reloading the page.
import { Routes } from '@angular/router';
import { HomeComponent } from './home.component';
import { AboutComponent } from './about.component';
export const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', redirectTo: '' }
];
<nav>
<a routerLink="/">Home</a>
<a routerLink="/about">About</a>
</nav>
<router-outlet></router-outlet>
SECTION 07Test yourself — Angular basics quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
What is the most important concept in Angular?
Components are the most important — they are the building blocks of every Angular app. Once you understand components, everything else falls into place.
Do I need to know TypeScript before Angular?
It helps, but you can learn TypeScript along the way. Angular uses TypeScript, so you'll pick it up naturally as you build components and services.
What is the difference between Angular and AngularJS?
Angular (2+) is a complete rewrite of AngularJS (1.x). Angular uses TypeScript, a component-based architecture, and is significantly faster and more modern.
Can I use Angular for small projects?
Yes — Angular is great for projects of all sizes. For very small projects, it may be overkill, but its structure helps as the project grows.
How long does it take to learn Angular basics?
With consistent practice, you can learn the basics in 2-4 weeks. Building a small project — like a to-do app — is the fastest way to learn.
SECTION 09Related reads
Classroom & online · Noida
Ready to build with Angular?
Our Data Analytics Training Course is designed to help you recover and rebuild — with skills, projects, and interview prep that get you hired.
₹15,500 · full programme- Complete Angular roadmap
- Skills & projects
- Mock interviews
- Weekday & weekend batches