Bird
0
0

What will happen if a component template contains multiple <ng-content> tags without select attributes?

medium📝 component behavior Q5 of 15
Angular - Component Interaction
What will happen if a component template contains multiple <ng-content> tags without select attributes?
AContent will be split evenly among all <code>ng-content</code> tags.
BAll projected content will appear in the first <code>ng-content</code> only.
CAngular will throw a compilation error.
DContent will appear duplicated in all <code>ng-content</code> tags.
Step-by-Step Solution
Solution:
  1. Step 1: Understand default ng-content behavior

    If no select attribute is provided, all content projects into the first ng-content found.
  2. Step 2: Confirm Angular behavior with multiple unnamed slots

    Angular does not split or duplicate content; it does not error either.
  3. Final Answer:

    All projected content will appear in the first <ng-content> only. -> Option B
  4. Quick Check:

    Unnamed ng-content = first slot only A [OK]
Quick Trick: Unnamed ng-content receives all content in first slot [OK]
Common Mistakes:
  • Expecting content to split automatically
  • Thinking Angular throws error for multiple unnamed slots
  • Assuming content duplicates in all slots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes