Angular 2 conditional ngFor
<li *ngFor="let a of (condition ? array1 : array2)">
<p>{{a.firstname}}</p>
<p>{{a.lastname}}</p>
</li>
You can make use of the ng-container
which is not recognised by DOM, hence will only be used for a condition. See example below:
<tr *ngFor="let company of companies">
<ng-container *ngIf="company.tradingRegion == 1">
<td>{{ company.name }}</td>
<td>{{ company.mseCode }}</td>
</ng-container>
</tr>
The code above will: `
Display a list of all companies where the tradingRegion == 1
`