简体   繁体   English

在 ngSwitchCase 中使用额外的参数

[英]Using extra parameter in ngSwitchCase

First of all, want to emphasize that I had already have a look at many pages eg Two switch case values in angular but they cannot fix my problem.首先,要强调的是,我已经看过很多页面,例如角度中的两个开关案例值,但它们无法解决我的问题。

I have the following approach in the html page of my Angular project and I switch according to i parameter without any problem.我在我的Angular项目的html页面中有以下方法,我根据i参数切换没有任何问题。 On the other hand, there is a parameter called loading on component side and I also need to use this value in ngSwitchCase .另一方面,组件端有一个名为loading的参数,我也需要在ngSwitchCase使用这个值。 But the following code does not work and ignore loading parameter's value.但以下代码不起作用并忽略loading参数的值。 So, how can I use it?那么,我该如何使用它呢?

<ng-container [ngSwitch]="i">
    <ng-container *ngSwitchCase="i === 0 && loading === true">
        <!-- other stuff -->
    </ng-container>
</ng-container>

Create another ng-container inside with the loading condition.在内部创建另一个具有loading条件的ng-container

<ng-container [ngSwitch]="i">
    <ng-container *ngSwitchCase="0">
        <ng-container *ngIf="loading">
            // do stuff
        </ng-container>
    </ng-container>
</ng-container>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM