Bird
0
0

You want to create a reusable Angular component that shows a user's name and age. Which approach correctly passes data to the component?

hard📝 Application Q8 of 15
Angular - Fundamentals
You want to create a reusable Angular component that shows a user's name and age. Which approach correctly passes data to the component?
AUse global variables to share name and age
BDeclare name and age as local variables inside the component only
CUse @Input properties to receive name and age from parent
DHardcode name and age inside the component template
Step-by-Step Solution
Solution:
  1. Step 1: Understand data flow in Angular

    Angular uses @Input properties to pass data from parent to child components, enabling reuse.
  2. Step 2: Evaluate other options

    Local variables don't receive external data, global variables break encapsulation, hardcoding is inflexible.
  3. Final Answer:

    Use @Input properties to receive name and age from parent -> Option C
  4. Quick Check:

    Data passing uses @Input decorator [OK]
Quick Trick: Use @Input to pass data into components [OK]
Common Mistakes:
  • Using global variables
  • Hardcoding data inside component

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes