Bird
0
0

Given this smart component template:

medium📝 component behavior Q4 of 15
Angular - Advanced Patterns
Given this smart component template:
<app-dumb [title]="pageTitle" (clicked)="onClicked()"></app-dumb>

And dumb component code:
@Input() title: string;
@Output() clicked = new EventEmitter();

handleClick() { this.clicked.emit(); }

What happens when the dumb component's button is clicked?
ANothing happens because clicked is not handled.
BThe dumb component updates the title property.
CThe smart component's onClicked() method is called.
DAn error occurs because clicked is not an input.
Step-by-Step Solution
Solution:
  1. Step 1: Understand event binding from dumb to smart

    The dumb component emits 'clicked' event. The smart component listens with (clicked) and calls onClicked().
  2. Step 2: Analyze what happens on button click

    When handleClick() emits clicked, smart component's onClicked() runs.
  3. Final Answer:

    The smart component's onClicked() method is called. -> Option C
  4. Quick Check:

    Output event triggers smart method [OK]
Quick Trick: Output events notify smart components [OK]
Common Mistakes:
  • Thinking clicked is an input property
  • Assuming dumb component changes inputs
  • Ignoring event binding syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes