Within my Angular 6 application, I am creating a table with the following structure:
Html:
<table>
<thead>
<tr>
<th>
Property Details
</th>
<th>
{{productOneDetails}}
</th>
<th>
{{productTwoDetails}}
</th>
</tr> <br>
</thead>
<tbody>
<tr *ngFor="let item of mergedArray">
<td> {{ item.property_name }} </td>
<td> {{ item.property_value }} </td>
<td> {{ item.property_value }} </td>
</tr>
</tbody>
</table>
In this setup, there are two arrays within the products
object - product one
and product two
.
The goal is to merge both sets of properties, this.productOneProperties
and this.productTwoProperties
, and display the combined result in the table.
All functionality currently works as intended.
Working example: https://stackblitz.com/edit/angular-iv8ckz
You will find the current output as follows:
Property Details Product One Product Two
Length 12cm 12cm
Width 10cm 10cm
Height 20cm 20cm
Color Red Red
Size Medium Medium
The desired expected output should be:
Property Details Product One Product Two
Length 12cm -
Width 10cm -
Height 20cm -
Color - Red
Size - Medium
To achieve this, it is necessary to merge both arrays and feature all properties under the Property Details
column.
If a property is only present in one product, the corresponding value should be displayed. Otherwise, show a "-" symbol for empty values.
I trust you understand my requirements and kindly request assistance converting the current output to match the expected output.