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 Data Streams

Learn how data can flow through an Observable over time and how Angular applications can work with synchronous and asynchronous data streams.

What is a Data Stream?

A data stream is a sequence of values that can become available one after another.

An Observable can represent that stream and emit values whenever they become available.

The values may represent numbers, strings, objects, HTTP responses, events or other application data.

Data Stream Flow

Data Source Produces Data
→
Observable Represents Stream
→
Subscriber Receives Values
→
Application Uses Data

Types of Data Streams

S
Synchronous

Values can be emitted immediately during execution.

A
Asynchronous

Values can arrive later as asynchronous work completes.

M
Multiple Values

A stream can emit multiple values over time.

T
Time Based

Some streams emit values according to time intervals.

Simple Data Stream

An Observable can emit a sequence of values one after another.

TypeScript
const numbers$ =
    new Observable<number>(subscriber => {

        subscriber.next(10);
        subscriber.next(20);
        subscriber.next(30);

        subscriber.complete();

    });

Stream Values

10

20

30

Creating a Stream with of()

The of() creation function can be used to create an Observable that emits the supplied values.

It is useful when we already have a small set of values that we want to represent as an Observable stream.

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

courses$.subscribe({

    next: course => {

        console.log(course);

    }

});

Creating a Stream with from()

The from() creation function can create an Observable from supported iterable or promise-like sources.

For example, an array can be converted into an Observable stream.

Example
const technologies = [
    'Angular',
    'TypeScript',
    'RxJS'
];

const technology$ =
    from(technologies);

technology$.subscribe({

    next: technology => {

        console.log(technology);

    }

});

Output

Angular

TypeScript

RxJS

Time-Based Data Stream

The interval() creation function produces sequential numbers at a specified time interval.

This is an example of a time-based Observable stream.

Example
const counter$ =
    interval(1000);

counter$.subscribe({

    next: value => {

        console.log(value);

    }

});

Example Output

0

1

2

3 ...

Data Stream Over Time

0 First Value
→
1 Next Value
→
2 Next Value
→
3 Next Value

Each emitted value becomes available to the subscriber through the next callback.

HTTP Response as a Data Stream

Angular HttpClient commonly exposes HTTP operations as Observables.

The application can subscribe to the Observable and receive the response when it becomes available.

Service
getCourses() {

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

}
Component
this.courseService
    .getCourses()
    .subscribe({

        next: courses => {

            this.courses = courses;

        },

        error: error => {

            console.error(error);

        }

    });

Event Data Stream

User interactions can also be represented as streams of events.

For example, repeated button clicks or input changes can produce a sequence of event values.

Example Concept
User Action
      ↓
Event Source
      ↓
Observable Stream
      ↓
Subscriber
      ↓
Application Logic

CIIT Training Institute Example

Suppose the CIIT Training Institute dashboard receives course enquiry updates throughout the day.

Every enquiry can become a value in a data stream. The dashboard can subscribe to that stream and process each enquiry.

Enquiry Data Stream
const enquiries$ =
    new Observable<string>(subscriber => {

        subscriber.next(
            'Java Full Stack enquiry'
        );

        subscriber.next(
            '.NET Full Stack enquiry'
        );

        subscriber.next(
            'Python Full Stack enquiry'
        );

        subscriber.complete();

    });
Subscribe
enquiries$.subscribe({

    next: enquiry => {

        console.log(
            'New enquiry:',
            enquiry
        );

    },

    complete: () => {

        console.log(
            'Enquiry stream completed'
        );

    }

});

CIIT Enquiry Dashboard

Java Full Stack enquiry

.NET Full Stack enquiry

Python Full Stack enquiry

Common Data Stream Sources

H
HTTP

API responses received asynchronously.

E
Events

User actions and browser events.

T
Timer

Values generated according to time.

D
Data Source

Application data represented as an Observable.

Data Stream Examples

Source Example Stream Behavior
Array from(technologies) Emits array values
Direct Values of(10, 20, 30) Emits supplied values
Timer interval(1000) Emits values periodically
HTTP http.get() Produces HTTP response data
Events User interaction Values can arrive as events occur

Data Stream States

N
Next

A value is emitted by the stream.

E
Error

The stream reports an error.

C
Complete

The stream finishes successfully.

U
Unsubscribe

The consumer stops its subscription.

Why Use Data Streams?

  • They represent values that can arrive over time.
  • They are useful for asynchronous application operations.
  • They provide a consistent way to consume different sources of data.
  • RxJS operators can transform and combine streams.
  • They are useful for HTTP, events, timers and other asynchronous scenarios.

Important Points

1. Stream Represents Sequence

A data stream represents values that can be emitted one after another.

2. Observable Represents the Stream

An Observable provides a way to represent and consume the data stream.

3. Values Can Arrive Over Time

Some streams emit values immediately while others produce values asynchronously.

4. Streams Can Be Transformed

RxJS operators can be applied when data needs to be transformed, filtered or combined.

Data Stream Best Practices

  • Understand where the stream data is coming from.
  • Use meaningful names for Observable variables.
  • Handle errors for important asynchronous operations.
  • Manage long-lived streams carefully.
  • Use RxJS operators when the data needs transformation.
  • Avoid unnecessary active subscriptions.

Summary

A data stream represents a sequence of values that can be emitted over time.

Angular applications can work with streams produced by HTTP calls, events, timers and other data sources.

Observables provide a way to represent and consume these streams. In the next topic, we will learn about Observable Operators.