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

Event Object in Angular

Learn how Angular provides the event object and how to access information about the event that occurred.

CIIT Training Institute

The event object helps Angular applications understand what happened during a user interaction, such as which key was pressed or what value was entered.

What is an Event Object?

When a DOM event occurs, the browser creates an object containing information about that event.

Angular provides this object through the $event variable.

👤 User Action User interacts
→
⚡ DOM Event Event occurs
→
$ $event Event information
→
🔧 Method Process event

The $event Variable

Angular provides the special $event variable inside an event binding expression.

Basic Example
<button (click)="handleClick($event)">
    Click Here
</button>
TypeScript
handleClick(event: MouseEvent) {

    console.log(event);

}

Mouse Event Object

Mouse events provide information such as the clicked element, mouse position and button information.

HTML
<button
    (click)="showMouseEvent($event)">

    Click for Event Details

</button>
TypeScript
showMouseEvent(event: MouseEvent) {

    console.log('Event Type:', event.type);
    console.log('Mouse X:', event.clientX);
    console.log('Mouse Y:', event.clientY);

}
Event Information:
Example Data:
Event Type: click
Mouse X: 450
Mouse Y: 280

Input Event Object

The input event object can be used to access the value entered by the user.

CIIT Course Enquiry
<input
    type="text"
    (input)="courseSearch($event)"
    placeholder="Search Angular course">
TypeScript
courseSearch(event: Event) {

    const value =
        (event.target as HTMLInputElement).value;

    console.log(value);

}
Live Example:

The entered value can be accessed through $event.

Keyboard Event Object

Keyboard events provide information about the key pressed by the user.

HTML
<input
    (keydown)="checkKey($event)"
    placeholder="Press any key">
TypeScript
checkKey(event: KeyboardEvent) {

    console.log(
        'Pressed Key:',
        event.key
    );

}
⌨️
event.key

Returns the key that was pressed.

🔢
event.keyCode

Represents keyboard information available from the event.

⚡
event.type

Returns the type of the event.

🎯
event.target

Identifies the element that generated the event.

Accessing the Event Target

The target property identifies the HTML element that generated the event.

Example
handleInput(event: Event) {

    const input =
        event.target as HTMLInputElement;

    console.log(input.value);

}

In this example, the event target is converted into an HTMLInputElement so that its value property can be accessed safely.

Common Event Object Properties

Property Purpose Example
type Returns event type click
target Returns event source element input
key Returns pressed keyboard key Enter
clientX Mouse X coordinate 450
clientY Mouse Y coordinate 280

Complete Example – CIIT Course Enquiry

Let's create a course enquiry example for CIIT Training Institute.

enquiry.component.html
<h2>
    CIIT Training Institute
</h2>

<input
    type="text"
    (input)="onCourseSearch($event)"
    placeholder="Enter course name">

<p>
    Searching:
    {{ searchText }}
</p>

<button
    (click)="submitEnquiry($event)">
    Submit Enquiry
</button>
enquiry.component.ts
searchText = '';

onCourseSearch(event: Event) {

    const input =
        event.target as HTMLInputElement;

    this.searchText = input.value;

}

submitEnquiry(event: MouseEvent) {

    console.log(
        'Enquiry submitted'
    );

    console.log(
        'Event:',
        event.type
    );

}
Expected Output:

CIIT Training Institute

Searching: Angular Full Stack

Event Object Flow

User Performs action
→
Browser Creates event
→
$event Receives object
→
Component Processes data
→
Application Responds

Event Object Best Practices

  • Use $event only when event information is required.
  • Use appropriate TypeScript event types such as MouseEvent and KeyboardEvent.
  • Convert event.target to the required HTML element type.
  • Keep event-processing logic inside component methods.
  • Avoid unnecessary access to the complete event object.
  • Use meaningful method names for event handlers.

Summary

Angular provides the $event object to access information about a DOM event.

Important event properties include type, target, key, clientX and clientY.

Understanding the event object helps developers build interactive applications such as course enquiry forms, registration forms and dashboards at CIIT Training Institute.