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>
我会尝试以下方法:
*ngIf="environment.id!=3 || environment.id!=1"
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 != 1 1
is != 3 3
is != 1 With OR
only one needs to match.
You might want
*ngIf="!(environment.id==3 || environment.id==1)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.