Bird
0
0

Given a parent component that listens to a child's event like this:

medium📝 component behavior Q4 of 15
Angular - Component Interaction
Given a parent component that listens to a child's event like this:
<app-child (notify)="onNotify($event)"></app-child>
What happens when the child calls this.notify.emit('hello')?
ANothing happens because emit is not connected
BAn error is thrown because emit needs a callback
CThe child component reloads
DThe parent's onNotify method is called with 'hello' as argument
Step-by-Step Solution
Solution:
  1. Step 1: Understand event binding

    The parent listens to the child's notify event and calls onNotify with the event data.
  2. Step 2: Trace the emit call

    When child emits 'hello', the parent's onNotify('hello') runs.
  3. Final Answer:

    The parent's onNotify method is called with 'hello' as argument -> Option D
  4. Quick Check:

    Child emit triggers parent handler with data [OK]
Quick Trick: Child emit triggers parent event handler [OK]
Common Mistakes:
  • Thinking emit does nothing without callback
  • Expecting child reload on emit
  • Confusing emit with error throwing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes