在ngSwitchCase中使用额外的参数 [英] Using extra parameter in ngSwitchCase
问题描述
首先,我想强调一下,我已经看过很多页面,例如两个有角度的开关案例值,但它们不能解决我的问题.
First of all, want to emphasize that I had already have a look at many pages e.g. Two switch case values in angular but they cannot fix my problem.
我在Angular
项目的html
页面中采用以下方法,并且根据i
参数进行切换没有任何问题.另一方面,在组件端有一个名为loading
的参数,我还需要在ngSwitchCase
中使用此值.但是以下代码不起作用,并且忽略了loading
参数的值.那么,我该如何使用呢?
I have the following approach in the html
page of my Angular
project and I switch according to i
parameter without any problem. On the other hand, there is a parameter called loading
on component side and I also need to use this value in ngSwitchCase
. But the following code does not work and ignore loading
parameter's value. So, how can I use it?
<ng-container [ngSwitch]="i">
<ng-container *ngSwitchCase="i === 0 && loading === true">
<!-- other stuff -->
</ng-container>
</ng-container>
推荐答案
使用loading
条件在其中创建另一个ng-container
.
Create another ng-container
inside with the loading
condition.
<ng-container [ngSwitch]="i">
<ng-container *ngSwitchCase="0">
<ng-container *ngIf="loading">
// do stuff
</ng-container>
</ng-container>
</ng-container>
这篇关于在ngSwitchCase中使用额外的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!