Input & Output Introduction
Learn how Angular components communicate with each other using Input and Output.
CIIT Training Institute
Angular Input and Output are mainly used for communication between parent and child components.
What is Component Communication?
Angular applications are built using multiple components. Sometimes one component needs to send information to another component.
Angular provides Input and Output to make this communication simple and organized.
Input vs Output
Input
Used to pass data from a parent component to a child component.
@Input()
Output
Used by a child component to communicate an event or value back to its parent.
@Output()
Communication
Components can exchange information in a structured way.
Parent ↔ Child
Reusable Design
Input and Output help create reusable Angular components.
Components
Parent to Child Communication
A parent component can send data to a child component using Input.
<app-course
[courseName]="selectedCourse">
</app-course>
@Input()
courseName = '';
Here the parent sends selectedCourse to the child component through the courseName Input property.
Child to Parent Communication
A child component can notify its parent about an event using Output.
@Output()
courseSelected = new EventEmitter<string>();
selectCourse() {
this.courseSelected.emit(
'Angular Full Stack'
);
}
<app-course
(courseSelected)="onCourseSelected($event)">
</app-course>
Input & Output Communication Flow
Complete Example – CIIT Course Selection
Suppose the CIIT Training Institute has a parent component that displays available courses and a child component that displays the selected course.
selectedCourse = 'Angular Full Stack';
courseSelected(course: string) {
this.selectedCourse = course;
}
<app-course-card
[courseName]="selectedCourse"
(courseChange)="courseSelected($event)">
</app-course-card>
@Input()
courseName = '';
@Output()
courseChange =
new EventEmitter<string>();
selectCourse(course: string) {
this.courseChange.emit(course);
}
CIIT Training Institute
Available Courses:
Communication Direction
| Feature | Direction | Purpose | Common Syntax |
|---|---|---|---|
| Input | Parent → Child | Pass data |
@Input()
|
| Output | Child → Parent | Send event/data |
@Output()
|
| EventEmitter | Child → Parent | Emit custom event |
EventEmitter
|
Why Use Input and Output?
Reusable Components
Components can receive different data and work in different situations.
Communication
Parent and child components can communicate clearly.
Data Flow
Application data flow becomes easier to understand.
Maintainability
Components remain focused on their individual responsibilities.
Input & Output Best Practices
- Use Input for parent-to-child data communication.
- Use Output for child-to-parent event communication.
- Give Input and Output properties meaningful names.
- Keep component communication simple and predictable.
- Avoid tightly coupling unrelated components.
- Use reusable child components whenever possible.
- Keep business logic in the appropriate component or service.
Summary
Angular Input and Output provide a standard way for components to communicate with each other.
Input is generally used for Parent → Child communication, while Output is used for Child → Parent communication.
These features are important for building modular and reusable applications such as the course, enquiry and registration modules of CIIT Training Institute.