I'm trying to create a directive which can take each <th>
heading, and place them as data tags in each <td>
. How can I transform this:
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Job Title</th>
<th>Favorite Color</th>
</tr>
</thead>
<tbody>
<tr>
<td>James</td>
<td>Matman</td>
<td>Chief Sandwich Eater</td>
<td>Lettuce Green</td>
</tr>
<tr>
<td>The</td>
<td>Tick</td>
<td>Crimefighter Sorta</td>
<td>Blue</td>
</tr>
</tbody>
</table>
To this:
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Job Title</th>
<th>Favorite Color</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="First Name">James</td>
<td data-label="Last Name">Matman</td>
<td data-label="Job Title">Chief Sandwich Eater</td>
<td data-label="Favorite Color">Lettuce Green</td>
</tr>
<tr>
<td data-label="First Name">The</td>
<td data-label="Last Name">Tick</td>
<td data-label="Job Title">Crimefighter Sorta</td>
<td data-label="Favorite Color">Blue</td>
</tr>
</tbody>
</table>
A few things to note are that the <th>
headings are static, but the data in the <td>
's are dynamic.
This is a unique problem, this question hasn't been asked before because I need to somehow get the <th>
value into the td
cell.