Bird
0
0

Examine this child component code:

medium📝 Debug Q6 of 15
Angular - Component Interaction
Examine this child component code:
@Component({ selector: 'child-comp', template: '{{data}}' }) export class ChildComponent { data: string; }

And the parent template:
<child-comp [data]="parentData"></child-comp>

What is the issue with this setup?
AThe child property 'data' lacks the @Input decorator, so it won't receive data from the parent.
BThe parent should use parentheses instead of square brackets for binding.
CThe child component's selector is incorrect.
DThe child template syntax '{{data}}' is invalid.
Step-by-Step Solution
Solution:
  1. Step 1: Check property declaration

    The child property data is declared without @Input.
  2. Step 2: Effect on binding

    Without @Input, Angular does not bind the parent's parentData to the child's data.
  3. Final Answer:

    The child property 'data' lacks the @Input decorator, so it won't receive data from the parent. -> Option A
  4. Quick Check:

    @Input decorator required for input binding [OK]
Quick Trick: Always add @Input to receive parent data [OK]
Common Mistakes:
  • Assuming public property automatically receives input
  • Confusing binding syntax in parent template
  • Ignoring missing decorator errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes