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 RxJS

Learn the fundamentals of RxJS and understand how RxJS works with Observables, streams and operators in Angular applications.

What is RxJS?

RxJS stands for Reactive Extensions for JavaScript. It is a library for reactive programming using Observables and other stream-processing features.

RxJS helps developers work with values that arrive over time and provides functions for creating, transforming, filtering, combining and controlling those streams.

Angular applications commonly use RxJS when working with asynchronous data and Observable-based APIs.

How RxJS Works

Data Source Produces Values
→
Observable Represents Stream
→
RxJS Operators Process Data
→
Subscriber Receives Result

Core RxJS Concepts

O
Observable

Represents a stream of values over time.

S
Subscriber

Consumes values emitted by an Observable.

P
pipe()

Connects RxJS operators into a processing pipeline.

O
Operators

Transform, filter and control Observable streams.

Importing RxJS

TypeScript
import {
    Observable,
    of,
    map,
    filter
} from '@rxjs';

RxJS Observable Example

RxJS can be used to create an Observable that emits values to a subscriber.

Example
const numbers$ =
    of(10, 20, 30);

numbers$.subscribe({

    next: value => {

        console.log(value);

    },

    complete: () => {

        console.log(
            'Completed'
        );

    }

});

Output

10

20

30

Completed

Using pipe() in RxJS

The pipe() method allows multiple RxJS operators to be applied to an Observable in sequence.

Each operator processes the stream and passes its result to the next stage.

Example
const numbers$ =
    of(1, 2, 3, 4, 5);

const result$ = numbers$.pipe(

    map(value => value * 10),

    filter(value => value > 20)

);

Result

30

40

50

RxJS Processing Pipeline

1, 2, 3, 4, 5 Source
→
map() × 10
→
filter() > 20
→
30, 40, 50 Final Result

RxJS vs Observable

Concept Meaning Example
RxJS Reactive programming library RxJS APIs
Observable Represents a stream of values Observable<number>
Operator Processes an Observable stream map(), filter()
Subscription Represents active Observable execution subscribe()

RxJS Creation Functions

O
of()

Creates an Observable from supplied values.

F
from()

Creates a stream from supported input sources.

I
interval()

Emits sequential values at regular intervals.

T
timer()

Creates time-based Observable sequences.

Transforming RxJS Data

RxJS operators can transform data before it reaches the subscriber.

For example, map() can convert each emitted value into another form.

Example
const courses$ = of(
    'Java',
    '.NET',
    'Python'
);

const courseNames$ =
    courses$.pipe(

        map(course =>
            course + ' Full Stack'
        )

    );

courseNames$.subscribe({

    next: course => {

        console.log(course);

    }

});

Filtering RxJS Data

The filter() operator allows only values that satisfy a condition to continue through the stream.

This is useful when the application needs only a subset of the incoming values.

Example
const fees$ = of(
    15000,
    25000,
    35000,
    45000
);

const selectedFees$ =
    fees$.pipe(

        filter(fee =>
            fee >= 30000
        )

    );

RxJS and Asynchronous Programming

RxJS is useful when an application needs to handle values that become available asynchronously.

HTTP requests, timers, events and other ongoing streams can be represented and processed using Observable-based patterns.

RxJS with Angular HttpClient

Service Example
getCourses() {

    return this.http.get<Course[]>(
        '/api/courses'
    );

}
Component Example
this.courseService
    .getCourses()
    .pipe(

        map(courses =>
            courses.filter(
                course => course.active
            )
        )

    )
    .subscribe({

        next: courses => {

            this.courses = courses;

        },

        error: error => {

            console.error(error);

        }

    });

CIIT Training Institute Example

Suppose the CIIT Training Institute dashboard receives different course enquiries.

RxJS can be used to process the enquiry stream before the final data is displayed in the dashboard.

Enquiry Stream
const enquiries$ = of(
    'Java',
    '.NET',
    'Python',
    'Data Analytics'
);
Process Stream
const result$ =
    enquiries$.pipe(

        map(course =>
            course + ' enquiry'
        ),

        filter(message =>
            message.includes(
                'Java'
            ) ||
            message.includes(
                '.NET'
            )
        )

    );

result$.subscribe({

    next: enquiry => {

        console.log(enquiry);

    }

});

CIIT Training Institute

Java enquiry

.NET enquiry

Benefits of RxJS

R
Reactive

Works naturally with values arriving over time.

C
Composable

Operators can be combined into processing pipelines.

A
Asynchronous

Useful for asynchronous application operations.

S
Stream Based

Represents and processes sequences of values.

Important RxJS APIs

API / Concept Purpose Example
Observable Represents a stream new Observable()
subscribe() Consumes emitted values observable.subscribe()
pipe() Connects operators observable.pipe(...)
map() Transforms values map(value => value * 2)
filter() Filters values filter(value => value > 10)

Important Points

1. RxJS Works with Streams

RxJS provides tools for working with values that arrive over time.

2. Observable is a Core Concept

Observables represent streams that can be consumed by subscribers.

3. Operators Process Data

Operators allow streams to be transformed, filtered, combined and controlled.

4. pipe() Builds the Pipeline

Multiple operators can be connected using pipe().

RxJS Best Practices

  • Give Observable variables meaningful names, commonly using a naming convention such as a trailing $.
  • Keep RxJS pipelines readable and avoid unnecessary complexity.
  • Use suitable operators instead of manually processing every emitted value.
  • Handle important asynchronous errors properly.
  • Manage long-lived subscriptions carefully.
  • Keep stream-processing logic separated from presentation logic where practical.

Summary

RxJS is a reactive programming library that provides Observables and operators for working with asynchronous and time-based data streams.

Important concepts include Observable, subscribe(), pipe() and operators.

In the next topic, we will study RxJS Operators in detail.