Bird
0
0

What does the Angular decorator @ContentChild do in a component?

easy📝 Conceptual Q11 of 15
Angular - Component Interaction
What does the Angular decorator @ContentChild do in a component?
AIt projects content from the component into its parent.
BIt creates a new child component inside the template.
CIt gets a reference to a single element inside the projected content.
DIt listens to events emitted by child components.
Step-by-Step Solution
Solution:
  1. Step 1: Understand content projection

    Content projection allows inserting external content inside a component using <ng-content>.
  2. Step 2: Role of @ContentChild

    @ContentChild gets a reference to a single element or directive inside that projected content.
  3. Final Answer:

    It gets a reference to a single element inside the projected content. -> Option C
  4. Quick Check:

    @ContentChild = reference to projected element [OK]
Quick Trick: Remember: @ContentChild targets projected content elements [OK]
Common Mistakes:
  • Confusing @ContentChild with @ViewChild
  • Thinking it creates new elements
  • Assuming it projects content instead of referencing it

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes