How to use <ng-template> with @if in angular version 17+

Discussão em 'Angular' iniciado por Dcode, Janeiro 26, 2025.

  1. Dcode

    Dcode Guest

    Here I'm trying to render if else using ng-template in classic way but this method is not working.

    <ng-template #temp>
    <p> Hi, I'm else part</p>
    </ng-template>


    @if(false) {
    <p>Hi, I'm a if part</p>
    }
    @else {
    <div *ngTemplateOutlet="temp"></div>
    }

    Continue reading...

Compartilhe esta Página