Updated on Kisan Patel
Content Projection in #Angular allows you to operate multiple <ng-content>
Use <ng-content select="selector">
to separate content you get (selector can be tag
, .class
or [attr]
)
Example:
wrapper.component.html
<ng-content select=".content"></ng-content> <div class="close-button"> <ng-content select="button"></ng-content> </div>
app.component.html
<wrapper *ngIf="show; else closed"> <button (click)="close()"> X </button> <div class="content"> Some content </div> </wrapper> <ng-template #closed> closed </ng-template>