Which of the following best explains why communication between Angular components is important?
Think about how different parts of an app work together and share information.
Components often need to share data or notify each other about events. This communication helps build interactive apps where parts respond to user actions or data changes.
Consider a parent component listening to an event emitted by its child component. What is the expected behavior when the child emits the event?
Child component: @Output() notify = new EventEmitter<string>(); Parent template: <child (notify)="onNotify($event)"></child>
Think about how events flow from child to parent in Angular.
When a child component emits an event, the parent can listen and respond by running a method with the event data.
When a parent passes data to a child component via @Input, how does Angular detect and respond to changes in that data?
Consider Angular's automatic update system for data binding.
Angular runs change detection regularly to update views when input properties change, keeping the UI in sync with data.
Which option shows the correct way to pass a string value title from a parent component to a child component using Angular's @Input?
Child component: @Input() title: string;
Remember that square brackets are used for property binding in Angular templates.
Square brackets [] bind a property from the parent to the child input property.
Given the following code, why does the child component not respond when the parent changes userName?
Parent component: userName = 'Alice'; Template:Child component: @Input() name: string; // No ngOnChanges or other lifecycle hooks used
Think about how Angular detects and reacts to input changes in child components.
Angular updates input properties automatically, but if the child needs to act on changes, it should implement ngOnChanges. Without it, the child may not respond to updates.