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 Binding in Angular

Learn how Angular connects DOM events with component methods using event binding syntax.

CIIT Training Institute

Event binding makes Angular applications interactive by allowing the component to respond to actions performed by users.

What is Event Binding?

Event binding is an Angular feature used to listen for events generated by HTML elements and execute component methods.

Angular uses parentheses () around the event name to create an event binding.

👤 User Performs an action
→
⚡ DOM Event click / input / keyup
→
🔗 Event Binding (click)
→
🔧 Component Method Method executes

Event Binding Syntax

Basic Syntax
<element (event)="method()">
    Content
</element>

(event) represents the DOM event and method() represents the component method that should execute when the event occurs.

Click Event Binding

The most common event binding is the click event.

student.component.html
<button (click)="welcomeStudent()">
    Welcome
</button>
student.component.ts
welcomeStudent() {

    console.log(
        'Welcome to CIIT Training Institute'
    );

}
Output:

CIIT Training Institute

Clicking the button calls welcomeStudent().

Passing Data with Event Binding

We can pass values from the template to the component method when an event occurs.

HTML
<button
    (click)="selectStudent('Sam')">
    Sam
</button>

<button
    (click)="selectStudent('Pradnya')">
    Pradnya
</button>

<button
    (click)="selectStudent('Samiksha')">
    Samiksha
</button>
TypeScript
selectStudent(name: string) {

    console.log(
        'Selected student: ' + name
    );

}

Event Binding with $event

Angular provides the $event object when we need information about the event.

HTML
<input
    type="text"
    (input)="onInput($event)"
    placeholder="Enter student name">
TypeScript
onInput(event: Event) {

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

    console.log(name);

}

Multiple Event Bindings

Multiple events can be handled on the same element.

Example
<input
    (focus)="onFocus()"
    (input)="onInput($event)"
    (blur)="onBlur()">
🔍
Focus

Executes when the input receives focus.

(focus)
⌨️
Input

Executes when the user changes the input value.

(input)
👋
Blur

Executes when the input loses focus.

(blur)
🖱️
Click

Executes when the element is clicked.

(click)

Common Event Binding Syntax

Event Angular Syntax Purpose
Click (click) Handle button or element clicks
Double Click (dblclick) Handle double-click actions
Input (input) Capture input changes
Change (change) Handle value changes
Key Down (keydown) Handle key press
Key Up (keyup) Handle key release
Focus (focus) Handle focus event
Blur (blur) Handle focus loss
Submit (submit) Handle form submission

Complete Example – CIIT Training Institute

student.component.ts
selectedStudent = '';

selectStudent(name: string) {

    this.selectedStudent = name;

}

welcomeStudent() {

    console.log(
        'Welcome to CIIT Training Institute'
    );

}
student.component.html
<h2>
    CIIT Training Institute
</h2>

<p>
    Select your name:
</p>

<button
    class="btn btn-primary me-2 mb-2"
    (click)="selectStudent('Sam')">
    Sam
</button>

<button
    class="btn btn-primary me-2 mb-2"
    (click)="selectStudent('Pradnya')">
    Pradnya
</button>

<button
    class="btn btn-primary mb-2"
    (click)="selectStudent('Samiksha')">
    Samiksha
</button>

<p class="mt-3">
    Selected Student:
    {{ selectedStudent }}
</p>

<button
    class="btn btn-success"
    (click)="welcomeStudent()">
    Welcome to CIIT
</button>
Expected Output:

CIIT Training Institute

Select your name:

Selected Student: Sam

Event Binding Flow

User Action Click / Input
→
Event DOM event occurs
→
Binding (click)
→
Method Component executes
→
Result UI / Logic updates

Event Binding Best Practices

  • Use parentheses () for event binding.
  • Keep event handler methods short and meaningful.
  • Use $event when event information is required.
  • Pass only the required values to component methods.
  • Avoid complex business logic inside the HTML template.
  • Use meaningful method names such as selectStudent().
  • Keep interactive components reusable and maintainable.

Summary

Angular Event Binding connects DOM events with component methods.

The basic syntax is: (event)="method()"

Event binding can handle click, input, keyboard, mouse and form events. The $event object can be used when information about the event is required.

Event binding is an important part of creating interactive applications at CIIT Training Institute.