I would like to display different template in my component. Only one will show.
If hasURL
is true
, I want to show the <a></a>
.
If hasURL
is false
, I want to show the <button></button>
.
The problem if hasURL is false, the component show button, but the ng-content is empty. Because it's already read in the first "a></a>
Is there a way to solve that please?
<a class="bouton" href="{{ href }}" *ngIf="hasURL">
<ng-content>
</ng-content>
</a>
<button class="bouton" *ngIf="!hasURL">
<ng-content>
</ng-content>
</button>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…