I have two string arrays and I want to iterate through one of them depends on condition. How can I avoid code duplication? Now *ngIf
for now:
<tr *ngIf="!condition">
<td *ngFor="let field of firstArray">{{field}}</td>
</tr>
<tr *ngIf="condition">
<td *ngFor="let field of secondArray">{{field}}</td>
</tr>
Is there a better way?
<tr>
<td *ngFor="let field of (condition ? secondArray : firstArray)">{{field}}</td>
</tr>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With