How to use multiple ng-content in the same component in Angular 2?
You can wrap ng-content
in ng-template
and use ngTemplateOutlet
<a class="bouton" href="{{ href }}" *ngIf="hasURL">
<ng-container *ngTemplateOutlet="contentTpl"></ng-container>
</a>
<button class="bouton" *ngIf="!hasURL">
<ng-container *ngTemplateOutlet="contentTpl"></ng-container>
</button>
<ng-template #contentTpl><ng-content></ng-content></ng-template>
Plunker Example
See also
- How to conditionally wrap a div around ng-content
Angular 9 demo