Bird
0
0

Given this component code:

medium📝 component behavior Q13 of 15
Angular - Template-Driven Forms
Given this component code:
export class MyComponent {
  name = 'Alice';
}

And this template snippet:
<input [(ngModel)]="name">
<p>Hello, {{ name }}!</p>

What will be displayed if the user types "Bob" in the input field?
AHello, Alice!
BHello, !
CHello, Bob!
DHello, {{ name }}!
Step-by-Step Solution
Solution:
  1. Step 1: Understand two-way binding effect on component property

    Typing "Bob" updates the name property in the component because of [(ngModel)].
  2. Step 2: Check template interpolation

    The paragraph uses {{ name }}, so it reflects the updated value "Bob" immediately.
  3. Final Answer:

    Hello, Bob! -> Option C
  4. Quick Check:

    Input changes update property and view [OK]
Quick Trick: Two-way binding updates both input and displayed text instantly [OK]
Common Mistakes:
MISTAKES
  • Thinking interpolation won't update after input change
  • Confusing interpolation syntax with literal text
  • Ignoring two-way binding effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes