Reputation: 78294
I am trying to loop though a list and want to show and element based on id.
If I do
*ngIf="environment.id!=3" then works.
cell is hidden. But I want to do
*ngIf="environment.id!=3 OR environment.id!=1"
which does not work.
<tr *ngFor="let environment of environments">
<td>{{ environment.name }}</td>
<td>
<a *ngIf="environment.id!=3 ? environment.id!=1" [routerLink]="['EditEnvironment', { id: environment.id }]">
<i class="icon icon-edit"></i>
</a>
</td>
<td>
<i (click)="deleteEnvironment(environment)" class="icon icon-cross"></i>
</td>
</tr>
Upvotes: 1
Views: 909
Reputation: 657546
This *ngIf
is always true
because every value is either != 3
or != 1
*ngIf="environment.id!=3 OR environment.id!=1"
2
is != 3 and also != 11
is != 33
is != 1With OR
only one needs to match.
You might want
*ngIf="!(environment.id==3 || environment.id==1)"
Upvotes: 1
Reputation: 202216
I would try the following:
*ngIf="environment.id!=3 || environment.id!=1"
Upvotes: 3