Bird
0
0

Given this component code:

medium📝 component behavior Q4 of 15
Angular - Template-Driven Forms
Given this component code:
export class UserComponent {
  username = 'John';
}

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

What will be displayed if the user types 'Anna' in the input?
AHello, John!
BHello, {{ username }}!
CHello, Anna!
DHello, !
Step-by-Step Solution
Solution:
  1. Step 1: Understand two-way binding effect

    Typing 'Anna' updates the username property immediately.
  2. Step 2: Check template interpolation

    The paragraph shows current username, so it updates to 'Anna'.
  3. Final Answer:

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

    Two-way binding updates display instantly [OK]
Quick Trick: Typing updates property and view instantly [OK]
Common Mistakes:
MISTAKES
  • Thinking interpolation won't update
  • Confusing one-way binding with two-way
  • Expecting initial value to remain

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes