是否有可能在angular.html中做两个ngIf?
一个例子:
if(1=2){
}else{
if(){
}
}
我需要做两次检查 .
检查教师的限制是否为假,以检查教室的可用性 .
下面是我的代码示例 . 我是棱角分明的新手,我不知道一切如何运作 .
<td *ngIf="!restricaoSegUm; else templateName" *ngIf="!restricaoSalaSegUm; else sala" [dragula]='"another-bag"' [dragulaModel]='segUm'>
<div [@resultadoAnimacao]="animationsState" class="cursor-pointer" *ngFor='let s1 of segUm' (dblclick)="removeNumbers(s1,this.segUm)">{{s1?.no_diciplinas}}</div>
</td>
<ng-template #templateName >
<td style="background-color: rgb(244, 67, 54);"></td>
</ng-template>
<ng-template-sala #sala>
<td style="background-color: rgb(244, 146, 54);"></td>
</ng-template-sala>
3 回答
你可以将2 * ngIf包装在一起 .
所以喜欢
您可以将
conditions
放在一个*ngFor
中,并且在单个元素上使用2*ngFor
是不正确的:你不应该放2 * ngIfs而是改为
*ngIf="conditions; then thenBlock; else elseBlock"
.在
conditions
部分,检查教师限制,一旦在templateName块中,您就可以确定要使用的背景颜色 .试试这个:
我不明白你的逻辑条件是什么评价,希望我指出你正确的方向 .