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 @Input

Learn how to use @Input to pass data from a parent component to a child component in Angular.

What is @Input?

In Angular, @Input is used when a parent component needs to send data to a child component.

The parent component provides the data using property binding, while the child component receives that data through an Input property.

This creates a simple and controlled way for components to communicate from Parent → Child.

Parent to Child Communication

Parent Component Provides Data
→
Property Binding [courseName]
→
Child Component @Input()

Basic @Input Syntax

Parent Component
<app-course-card
    [courseName]="selectedCourse">
</app-course-card>
Child Component
import { Component, Input } from '@angular/core';

@Component({
    selector: 'app-course-card',
    templateUrl: './course-card.component.html'
})
export class CourseCardComponent {

    @Input() courseName = '';

}

How @Input Works

1
Parent Has Data

The parent component contains the value that needs to be shared.

2
Property Binding

The value is passed using Angular property binding.

3
Child Receives Data

The child component receives the value through @Input.

4
Child Uses Data

The child can display or process the received value.

Simple @Input Example

Parent Component
export class CourseComponent {

    selectedCourse = 'Full Stack .NET';

}
Parent HTML
<app-course-card
    [courseName]="selectedCourse">
</app-course-card>
Child Component
import { Component, Input } from '@angular/core';

@Component({
    selector: 'app-course-card',
    templateUrl: './course-card.component.html'
})
export class CourseCardComponent {

    @Input() courseName = '';

}
Child HTML
<div class="course-card">

    <h3>{{ courseName }}</h3>

    <p>
        Welcome to CIIT Training Institute.
    </p>

</div>

Output

Full Stack .NET

Welcome to CIIT Training Institute.

Using Property Binding with @Input

The square bracket syntax [property] is used to bind a parent component property to a child component Input.

Property Binding
<app-course-card
    [courseName]="selectedCourse">
</app-course-card>
selectedCourse Parent Property
→
[courseName] Property Binding
→
@Input() Child Property

Multiple @Input Properties

A child component can receive multiple values from its parent component.

Child Component
import { Component, Input } from '@angular/core';

@Component({
    selector: 'app-course-card',
    templateUrl: './course-card.component.html'
})
export class CourseCardComponent {

    @Input() courseName = '';
    @Input() duration = '';
    @Input() fees = 0;
    @Input() onlineAvailable = false;

}
Parent HTML
<app-course-card
    [courseName]="course"
    [duration]="duration"
    [fees]="fees"
    [onlineAvailable]="online">
</app-course-card>

Complete CIIT Training Institute Example

Suppose the CIIT Training Institute course page has a parent component containing course information.

That information can be passed to a reusable course-card child component using multiple @Input properties.

Parent Component
export class CoursesComponent {

    course = 'Java Full Stack';
    duration = '6 Months';
    fees = 35000;
    online = true;

}
Parent Template
<app-course-card
    [courseName]="course"
    [duration]="duration"
    [fees]="fees"
    [onlineAvailable]="online">
</app-course-card>
Child Component
import { Component, Input } from '@angular/core';

@Component({
    selector: 'app-course-card',
    templateUrl: './course-card.component.html'
})
export class CourseCardComponent {

    @Input() courseName = '';
    @Input() duration = '';
    @Input() fees = 0;
    @Input() onlineAvailable = false;

}
Child Template
<div class="course-card">

    <h3>{{ courseName }}</h3>

    <p>
        Duration: {{ duration }}
    </p>

    <p>
        Fees: ₹{{ fees }}
    </p>

    <p>
        Online Training:
        {{ onlineAvailable ? 'Available' : 'Not Available' }}
    </p>

</div>

Different Types of Data

Data Type Input Example Purpose
String @Input() courseName = '' Course name or text
Number @Input() fees = 0 Course fees
Boolean @Input() onlineAvailable = false True / False values
Object @Input() course = { } Multiple related values
Array @Input() topics = [ ] List of topics

Important Points

1. Parent → Child

@Input is mainly used for passing data from a parent component to a child component.

2. Use Property Binding

Use square brackets such as [courseName] when binding dynamic values.

3. Keep Child Components Reusable

Passing data through Inputs allows the same child component to be reused with different values.

4. Use Meaningful Names

Input property names should clearly describe the data being received.

@Input Best Practices

  • Use @Input for Parent → Child communication.
  • Use meaningful Input property names.
  • Keep child components focused and reusable.
  • Use property binding for dynamic values.
  • Keep data flow clear between components.
  • Avoid unnecessary duplicate data in child components.

Summary

Angular @Input allows a parent component to send data to a child component. The parent uses property binding, while the child receives the value through an Input property. This makes Angular components reusable and keeps communication between components organized.