Bird
0
0

Which syntax correctly creates a named slot using ng-content in Angular?

easy📝 Syntax Q12 of 15
Angular - Component Interaction
Which syntax correctly creates a named slot using ng-content in Angular?
A<ng-content select=".header"></ng-content>
B<ng-content name="header"></ng-content>
C<ng-content slot="header"></ng-content>
D<ng-content id="header"></ng-content>
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct attribute for named slots

    Angular uses the select attribute on ng-content to create named slots by CSS selectors.
  2. Step 2: Check each option

    Only uses select with a CSS class selector, which is correct syntax.
  3. Final Answer:

    <ng-content select=".header"></ng-content> -> Option A
  4. Quick Check:

    Named slot uses select attribute [OK]
Quick Trick: Use select="CSS-selector" for named ng-content slots [OK]
Common Mistakes:
  • Using name or slot attributes which Angular does not support
  • Confusing with Web Components slot attribute
  • Using id attribute instead of select

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes