Bird
0
0

Consider this Angular template:

medium📝 component behavior Q5 of 15
Angular - Templates and Data Binding
Consider this Angular template:
<input (input)="updateName($event.target.value)">
<p>Name: {{name}}</p>

If the user types 'Anna', what will be the value of name after typing?
AAnna
B$event
Cundefined
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Understand event binding with $event

    The (input) event passes the input's value to updateName method.
  2. Step 2: Recognize that updateName sets the name

    The method sets the component's name property to the typed value.
  3. Final Answer:

    Anna -> Option A
  4. Quick Check:

    Input event updates name to typed value [OK]
Quick Trick: Use $event.target.value to get input value [OK]
Common Mistakes:
  • Using $event instead of $event.target.value
  • Not updating the component property
  • Assuming name stays undefined

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes