Forgive me if this is a basic question, but I am new to Angular 9 and json. I am attempting to iterate through a list and only create a table row if the correct ID matches the ID passed from the previous page link.
I am struggling to make the if statement work within the for loop, as it is not generating any output.
<table>
<tr *ngFor="let tag of tags; if tag.id == tagged.id">
<th>{{ tag.id }}</th>
<th>{{ tag.manufacturer }}</th>
<th>{{ tag.serial }}</th>
<th>{{ tag.inspectedDate }}</th>
<th>{{ tag.result }}</th>
<th>{{ tag.actionNeeded }}</th>
<th>{{ tag.inspectee }}</th>
<th>{{ tag.certificateNumb }}</th>
<th>{{ tag.nextInspection }}</th>
</tr>
</table>
I have managed to get it working by using the following code, but I am aware that this is not the most efficient method and I am struggling to find or figure out the correct way to do it:
<table>
<tr *ngFor="let tag of tags">
<th *ngIf="tag.id == tagged.id">{{ tag.id }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.manufacturer }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.serial }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.inspectedDate }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.result }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.actionNeeded }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.inspectee }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.certificateNumb }}</th>
<th *ngIf="tag.id == tagged.id">{{ tag.nextInspection }}</th>
</tr>
</table>