Bird
0
0

Identify the issue in this Angular component template:

medium📝 Debug Q6 of 15
Angular - Component Interaction
Identify the issue in this Angular component template:
<div>
  <ng-content select=".nav"></ng-content>
  <ng-content select="nav"></ng-content>
</div>
Ang-content requires a default slot without select attribute.
BMultiple ng-content tags cannot be used in the same template.
CThe select attribute cannot contain CSS selectors.
DThe second select uses a tag selector 'nav' which may not match intended elements.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze selectors

    The first select=".nav" matches elements with class 'nav'. The second select="nav" matches elements with tag name 'nav'.
  2. Step 2: Identify potential mismatch

    If usage only has elements with class 'nav' but no <nav> tags, the second slot won't project anything.
  3. Step 3: Confirm no syntax error

    Multiple ng-content tags are allowed, and CSS selectors are valid.
  4. Final Answer:

    The second select uses a tag selector 'nav' which may not match intended elements. -> Option D
  5. Quick Check:

    Class vs tag selector mismatch causes projection issues [OK]
Quick Trick: Select attribute must match intended element types [OK]
Common Mistakes:
  • Believing multiple ng-content tags are disallowed
  • Thinking select cannot use CSS selectors
  • Assuming default slot is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes