0 day streak
javascript / beginner
Snippet

Reusable Components with ng-content

The <ng-content> tag acts as a placeholder for external content, allowing you to project HTML from a parent component into a child component.

snippet.js
javascript
1
2
3
4
5
6
7
<!-- card.component.html -->
<div class="card">
<div class="card-header">Title</div>
<div class="card-body">
<ng-content></ng-content>
</div>
</div>
angular
Breakdown
1
<ng-content></ng-content>
Specifies where the projected content from the parent should be placed.