Bird
0
0

How do you define a named slot in Angular that projects elements with the CSS class footer?

easy📝 Syntax Q3 of 15
Angular - Component Interaction
How do you define a named slot in Angular that projects elements with the CSS class footer?
A<ng-content select=".footer"></ng-content>
B<ng-content select="#footer"></ng-content>
C<ng-content select="footer"></ng-content>
D<ng-content select="[footer]"></ng-content>
Step-by-Step Solution
Solution:
  1. Step 1: Understand CSS selector syntax in ng-content

    The select attribute uses CSS selectors to match elements for projection.
  2. Step 2: Identify correct selector for class

    Classes are selected with a dot prefix, so .footer is correct.
  3. Step 3: Eliminate incorrect selectors

    #footer selects by id, footer selects by tag name, and [footer] selects by attribute.
  4. Final Answer:

    <ng-content select=".footer"></ng-content> -> Option A
  5. Quick Check:

    Class selector = dot prefix [OK]
Quick Trick: Use .class selector in select attribute for named slots [OK]
Common Mistakes:
  • Using id selector (#footer) instead of class selector
  • Using tag name selector instead of class
  • Confusing attribute selector syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes