Bird
0
0

Given this component code:

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

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

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

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

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

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

    Typing updates property and view = Hello, Bob! [OK]
Quick Trick: Typing changes property, interpolation updates view [OK]
Common Mistakes:
MISTAKES
  • Thinking interpolation won't update after typing
  • Confusing initial value with updated value
  • Ignoring two-way binding effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes