如何引用td
单元以角度引用报头的ID?
在jQuery中
var $th = $td.closest('table').find('th').eq($td.index());
但是否寻找有角度的6种方式?
<table>
<tr>
<th id="open">Open</th>
<th id="close">Close</th>
<th id="custom">
<select [(ngModel)]="customSel">
<option>Mid</option>
<option>High</option>
<option>Low</option>
</select>
</th>
</tr>
<tbody>
// call a function that has basic stat and store into nested obj
<ng-container *ngFor="let res of ObjData| keyvalue">
<tr *ngIf="res.key === 'mean' ">
//here. how can I reference to the corresponding ID.
//the problem now is it might not be in order and I have a custom header that would need to be referenced.
<td *ngFor="let item of res.value |keyvalue "> {{item.value}} </td>
</tr>
</ng-container>
</tbody>
</table>
其中ObjData
是:
mean: {Open: "17.68429", Close: "17.69331", Low: "17.39524", High: "18.00872", Mid: "17.70198"}
median: {Open: "17.57500", Close: "17.58500", Low: "17.25000", High: "17.87000", Mid: "17.55497"}
输出将具有打开和关闭以及自定义的平均值