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

RxJS Transformation & Filtering

Learn how RxJS operators transform Observable values and filter unwanted data before it reaches the subscriber.

What are Transformation and Filtering?

Transformation means changing each emitted value into another value or format.

Filtering means allowing only those values that satisfy a specific condition to continue through the stream.

RxJS provides operators such as map() for transformation and filter() for filtering.

Transformation and Filtering Flow

Source Original Values
→
map() Transform Values
→
filter() Keep Required Values
→
Subscriber Receives Result

What is Transformation?

Transformation changes the data emitted by the source Observable into another form.

For example, numbers can be multiplied, strings can be formatted, or objects can be converted into another structure.

map() Operator

The map() operator applies a transformation function to every value emitted by the source Observable.

The transformed value is emitted by the resulting Observable.

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

const result$ = numbers$.pipe(

    map(value => value * 2)

);

result$.subscribe({

    next: value => {

        console.log(value);

    }

});

Output

20

40

60

map() Transformation Flow

10 Original
→
× 2 map()
→
20 Transformed

String Transformation

map() can also transform strings into another format.

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

const fullStackCourses$ =
    courses$.pipe(

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

    );

fullStackCourses$.subscribe({

    next: course => {

        console.log(course);

    }

});

Output

Java Full Stack

.NET Full Stack

Python Full Stack

Object Transformation

map() can also extract or create a different value from an object emitted by an Observable.

This is useful when the application needs only a specific property from a larger object.

Example
const courses$ = of(

    {
        name: 'Java Full Stack',
        duration: '6 Months'
    },

    {
        name: '.NET Full Stack',
        duration: '6 Months'
    }

);

const names$ = courses$.pipe(

    map(course => course.name)

);

names$.subscribe({

    next: name => {

        console.log(name);

    }

});

What is Filtering?

Filtering means selecting only the values that match a specified condition.

RxJS provides the filter() operator for this purpose.

filter() Operator

The filter() operator checks every emitted value against a condition.

Only values for which the condition is true continue through the resulting Observable.

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

const evenNumbers$ =
    numbers$.pipe(

        filter(value =>
            value % 2 === 0
        )

    );

evenNumbers$.subscribe({

    next: value => {

        console.log(value);

    }

});

Filtered Output

10

20

30

Filtering Strings

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

const angularCourses$ =
    courses$.pipe(

        filter(course =>
            course === 'Angular'
        )

    );

angularCourses$.subscribe({

    next: course => {

        console.log(course);

    }

});

Output

Angular

Filtering Objects

Objects can be filtered using one or more of their properties.

This is useful when the application wants to display only matching records.

Example
const courses$ = of(

    {
        name: 'Java Full Stack',
        active: true
    },

    {
        name: '.NET Full Stack',
        active: false
    },

    {
        name: 'Python Full Stack',
        active: true
    }

);

const activeCourses$ =
    courses$.pipe(

        filter(course =>
            course.active
        )

    );

Combining map() and filter()

Transformation and filtering can be combined in the same RxJS pipeline.

The order of operators matters because each stage processes the output from the previous stage.

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

const result$ = numbers$.pipe(

    map(value => value * 10),

    filter(value =>
        value >= 30
    )

);

result$.subscribe({

    next: value => {

        console.log(value);

    }

});

Output

30

40

50

Operator Order Matters

1 2 3 4 5 Source
→
map() × 10
→
10 20 30 40 50 Transformed
→
filter() ≥ 30
→
30 40 50 Result

Filtering Before Transformation

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

const result$ = numbers$.pipe(

    filter(value =>
        value >= 30
    ),

    map(value =>
        value / 10
    )

);

result$.subscribe({

    next: value => {

        console.log(value);

    }

});

Output

3

4

5

map() vs filter()

Feature map() filter()
Purpose Transform values Select values
Output Transformed value Original matching value
Condition Not required Usually required
Example value * 2 value > 10
Main Use Change data Keep required data

CIIT Training Institute Example

Suppose CIIT Training Institute has a stream of course information containing course name and fees.

We can first select courses above a particular fee and then transform the matching objects into display-friendly text.

Course Data
const courses$ = of(

    {
        name: 'Java Full Stack',
        fees: 25000
    },

    {
        name: '.NET Full Stack',
        fees: 35000
    },

    {
        name: 'Python Full Stack',
        fees: 40000
    }

);
Transform and Filter
const premiumCourses$ =
    courses$.pipe(

        filter(course =>
            course.fees >= 35000
        ),

        map(course =>
            course.name +
            ' - ₹' +
            course.fees
        )

    );

premiumCourses$.subscribe({

    next: course => {

        console.log(course);

    }

});

CIIT Training Institute

.NET Full Stack - ₹35000

Python Full Stack - ₹40000

Practical Search Example

A common use case is filtering search results and then transforming the selected data for display.

For example, a course search can keep only matching courses and then return their names.

Example
const courses$ = of(
    'Java Full Stack',
    '.NET Full Stack',
    'Python Full Stack',
    'Data Analytics'
);

const result$ = courses$.pipe(

    filter(course =>
        course.includes('Full Stack')
    ),

    map(course =>
        course.toUpperCase()
    )

);

result$.subscribe({

    next: course => {

        console.log(course);

    }

});

Search Result

JAVA FULL STACK

.NET FULL STACK

PYTHON FULL STACK

Transformation & Filtering Best Practices

  • Use map() when the emitted value needs to be transformed.
  • Use filter() when only values matching a condition should continue.
  • Keep transformation functions simple and readable.
  • Consider the order of operators when multiple operators are chained.
  • Avoid unnecessary transformations when the source data is already in the required format.
  • Keep complex business rules outside the presentation layer where practical.

Important Points

1. map() Changes Values

map() transforms each emitted value into another value.

2. filter() Selects Values

filter() allows only values that satisfy its condition.

3. Operators Can Be Chained

map() and filter() can be combined in a single pipe() pipeline.

4. Operator Order Matters

Each operator receives the output produced by the previous stage in the pipeline.

Summary

RxJS transformation changes emitted values into another form using operators such as map().

Filtering selects only the values that satisfy a condition using filter().

These operators can be combined inside pipe() to create a useful data-processing pipeline. In the next topic, we will learn about Combining Observables.