- how to use ngIf, else and then in angular

 


app.component.html:

<h1>Welcome to {{title}}</h1>

  <h1>ngIf Tutorial</h1>

 

 <input type="radio" name="radio1" (click)="showblock(true)">Block1

 <input type="radio" name="radio1" (click)="showblock(false)">Block2

 

<div *ngIf="block ; then block1 ; else block2"></div>

 

<ng-template #block1>

  <div>

    <p>You are under block1</p>

  </div>

</ng-template>

 

<ng-template #block2>

  <div>

    <p>you are under block2</p>

  </div>

</ng-template>

Post a Comment

Previous Post Next Post