Concept Flow - Why component communication matters
Parent Component
Child Component
Sibling Component
Shows how components pass data and events between each other to keep the app working together.
import { Component, Input, Output, EventEmitter } from '@angular/core'; /* Parent passes message to Child */ @Component({selector:'app-parent', template: `<app-child [message]="message" (notify)="onNotify($event)"></app-child>`}) export class Parent { message = 'Hello Child'; onNotify(event: string) { console.log('Received event:', event); } } /* Child receives input and emits event */ @Component({selector:'app-child', template: `<button (click)="notify.emit('Clicked!')">Click me</button>`}) export class Child { @Input() message!: string; @Output() notify = new EventEmitter<string>(); }
| Step | Action | Component | Data/State | Event Emitted | Resulting Communication |
|---|---|---|---|---|---|
| 1 | Parent sets message | Parent | message = 'Hello Child' | None | Data ready to pass down |
| 2 | Parent passes message to Child input | Child | message = 'Hello Child' | None | Child receives data |
| 3 | Child user clicks button | Child | message unchanged | notify.emit('Clicked!') | Child sends event up |
| 4 | Parent listens to notify event | Parent | message unchanged | Received 'Clicked!' | Parent reacts to child event |
| 5 | Parent updates sibling data | Sibling | updated by Parent | None | Sibling updates UI |
| 6 | No communication | Any | isolated state | None | Components do not sync |
| 7 | Exit | N/A | N/A | N/A | Communication flow ends |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| Parent.message | '' | 'Hello Child' | 'Hello Child' | 'Hello Child' | 'Hello Child' | 'Hello Child' |
| Child.message | undefined | 'Hello Child' | 'Hello Child' | 'Hello Child' | 'Hello Child' | 'Hello Child' |
| Child.notify Event | none | none | none | 'Clicked!' | 'Clicked!' | none |
| Sibling.data | '' | '' | '' | '' | 'updated by Parent' | 'updated by Parent' |
Angular components communicate by passing data down via @Input and sending events up via @Output. Parent components control data flow and update siblings based on child events. Without communication, components act isolated causing inconsistent UI. Use event emitters for child-to-parent messages and inputs for parent-to-child data. This keeps the app reactive and synchronized.