Master Angular From Scratch

Learn Angular with clear, interactive, and structured lessons for beginners and developers.

ANGULAR COURSE SYLLABUS
1. Angular Introduction
Angular Introduction Angular History Angular Fundamentals Angular Architecture Component-Based Angular
2. Angular Setup
Angular Setup Introduction Installing Node.js Installing Angular CLI Creating an Angular Application Angular Project Structure
3. Components
Components Overview Component Anatomy Creating Components Component Selector Component Template Component Styles Component Metadata Standalone Components Parent and Child Components Reusable Components
4. Templates
Templates Introduction Template Syntax Template Expressions Template Statements Template Reference Variables ng-template ng-container ngTemplateOutlet Built-in Control Flow
5. Data Binding
Data Binding Introduction Interpolation Binding Property Binding Event Binding Two-Way Data Binding Class & Style Binding
6. Directives
Directives Introduction Attribute Directives Structural Directives Custom Directives
7. Pipes
Pipes Introduction Built-in Pipes Parameterized Pipes Chaining Pipes Custom Pipes
8. Event Handling
Event Handling Introduction DOM Events Event Binding Syntax Event Object Passing Data to Event Handlers
9. Input & Output
Component Communication @Input @Output EventEmitter
10. Lifecycle Hooks
Lifecycle Hooks Introduction ngOnInit ngOnChanges ngAfterViewInit ngOnDestroy
11. Services
Services Introduction Creating Angular Services Using Services in Components Sharing Data Through Services Service Scope
12. Dependency Injection
Dependency Injection Introduction Injecting Dependencies InjectionToken Provider Configuration
13. Routing
Routing Introduction Route Configuration RouterLink & Navigation Route Parameters Child Routes Route Guards
14. Forms
Angular Forms Introduction Template-Driven Forms Reactive Forms Form Validation Form Submission & Error Handling
15. HttpClient
HttpClient Introduction Configuring HttpClient GET Request POST, PUT & DELETE Requests Headers & Parameters HTTP Error Handling
16. Observables
Observables Introduction Creating & Subscribing to Observables Observable Data Streams Observable Operators Subscription Management
17. RxJS
RxJS Introduction RxJS Operators Transformation & Filtering Combining Observables Higher-Order Mapping Subjects
18. API Integration
API Integration Introduction Connecting Angular with REST API Consuming API Data CRUD API Integration API Response & Error Handling

Angular Components

Components are the basic building blocks of an Angular application. A component controls a specific part of the user interface and contains the logic, template and styling required for that part.

What is an Angular Component?

An Angular component is a TypeScript class connected to an HTML template. It can also have styles that control the appearance of the component.

Components help developers divide a large application into smaller, manageable and reusable parts.

Simple Definition: Component = TypeScript Logic + HTML Template + Styling

Basic Structure of a Component

1

TypeScript

Contains component logic, properties and methods.

+
2

HTML Template

Defines what the user sees on the screen.

+
3

CSS

Defines the appearance and styling of the component.

=
✓

Angular Component

Complete reusable UI component.

Simple Component Example

Let's create a simple Student component that displays the name of a student.

student.component.ts
import { Component } from '@angular/core';

@Component({
    selector: 'app-student',
    templateUrl: './student.component.html'
})
export class StudentComponent {

    studentName = 'Sam';

}

The component template can display the student name using Angular interpolation.

student.component.html
<h2>Student Details</h2>

<p>
    Student Name: {{ studentName }}
</p>

Expected Output

Student Details

Student Name: Sam

@Component Decorator

The @Component decorator tells Angular that a TypeScript class should be treated as a component.

Component Decorator
@Component({
    selector: 'app-student',
    templateUrl: './student.component.html'
})

Component Metadata

Metadata inside the @Component decorator tells Angular how the component should behave and where its template is located.

Component Selector

The selector defines how the component is placed inside another Angular template.

student.component.ts
@Component({
    selector: 'app-student'
})

The component can then be used in an HTML template like this:

HTML Template
<app-student></app-student>

Component Tree

Angular applications can contain many components. These components can be organized into parent and child components.

AppComponent
│
HeaderComponent
StudentComponent
FooterComponent

Responsibilities of a Component

1
User Interface

Displays the required part of the application.

2
Application Logic

Contains TypeScript properties and methods.

3
User Interaction

Handles user actions and events.

4
Data Display

Displays application data in the template.

Benefits of Angular Components

✓

Divide a large application into smaller sections.

✓

Make application code easier to maintain.

✓

Create reusable user interface elements.

✓

Improve application organization.

Complete Component Flow

1
Component Class TypeScript logic
→
2
Template HTML user interface
→
3
Angular Connects component and template
→
4
Browser Displays the component

Summary

Angular components are the basic building blocks of Angular applications.

A component contains TypeScript logic and an HTML template, along with optional styling.

Components make Angular applications modular, reusable and easier to maintain.