Angular multiple ngif else passing parameter in template

0

Is it possible to do two ngIf in the angular.html? follows an example

if(1=2){
}else{
    if(){
    }
}

I need to do two checks.

Check teacher restriction if false to check classroom availability.

if an example of my code. I'm new to angular and I do not know how everything works.

<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>

Any help on how to solve?

    
asked by anonymous 13.02.2018 / 20:48

1 answer

0

Sometimes writing in pseudocode helps to clarify the purpose:

se restricaoSegUm == False && restricaoSalaSegUm == False então
    mostrar <div class="cursor-pointer">
senao
    se restricaoSegUm == True então
        mostrar <ng-template #templateName>
    senao se restricaoSalaSegUm == True então
        mostrar <ng-template-sala #sala>

Using the NgIf directive (Angular 4 and 5)

<td *ngIf="!restricaoSegUm && !restricaoSalaSegUm"
    [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 *ngIf="restricaoSegUm; else sala" #templateName>
    <td style="background-color: rgb(244, 67, 54);"></td>
</ng-template>

<ng-template-sala *ngIf="restricaoSalaSegUm" #sala>
    <td style="background-color: rgb(244, 146, 54);"></td>
</ng-template-sala>
    
14.02.2018 / 00:16