Is there any way for ngIf else to send value into it?

I want to add a section of reusability of code. Code looks like this.

<ng-container *ngIf="foo === "1";else qq1"></ng-container>
<ng-container *ngIf="foo === "2";else qq2"></ng-container>

<ng-template -sharpqq1>
    <ng-container *ngFor="let inside of list>
        <ng-container *ngIf="inside[3] == "1"">
            {{inside[0]}}{{inside[2]}}
        </ng-container>
    </ng-container>
</ng-template>
<ng-template -sharpqq2>
    <ng-container *ngFor="let inside of list>
        <ng-container *ngIf="inside[3] == "2"">
            {{inside[0]}}{{inside[2]}}
        </ng-container>
    </ng-container>
</ng-template>

mainly wants to merge-sharpqq1 and-sharpqq2 into one, because only the number after ngIf changes

.

to achieve this effect, I have to send a value to the qq of else

want to know if there is a way to pass in numerical values?

Jun.23,2022

there is something wrong with the logic of this code. What are your requirements and why there is an if based on a specific value. If foo equals 3, all the code above you can be simplified a lot.


can be passed the same as directly written variables in ts can be read.

Menu