Angular · Junior · Question 28 of 75
What is <ng-content /> used for?
<!-- card.html -->
<div class="card"><ng-content /></div>
<!-- usage -->
<app-card><p>Any content</p></app-card>- ✓Correct answer: Content projection: it renders the markup that the parent puts between the component tags
- 2It loads content from the server
- 3It renders the component's own template a second time
Explanation
It is the Angular equivalent of children in React or slots in Vue. Several slots can be selected with <ng-content select="[card-title]" />.