Franavi
Franavi

Reputation: 47

condition with two *ngIf and one else

I am trying to apply the following, is it possible to achieve with ngIf? that it is not necessary to use ngSwitch I would appreciate any help

    if(){
    }elseif(){
    }else{
    }
<p *ngIf="document.userDocument.approver1.status == 'Approved';
                        else pending
                      ">
  <nb-icon icon="checkmark-outline"></nb-icon> Approved
</p>
<p *ngIf="document.userDocument.approver1.status == 'Rejected';
                        else pending
                      ">
  <nb-icon icon="close-outline"></nb-icon> Rejected
</p>
<ng-template #pending>
  <nb-icon icon="clock-outline"></nb-icon> Pending approval
</ng-template>

Upvotes: 0

Views: 199

Answers (1)

jaibalaji
jaibalaji

Reputation: 3475

Another alternative is to nest conditions

<ng-container *ngIf="foo === 1;else second"></ng-container>
<ng-template #second>
    <ng-container *ngIf="foo === 2;else third"></ng-container>
</ng-template>
<ng-template #third></ng-template>

Upvotes: 1

Related Questions