表格标题中的参考ID(角度6)

时间:2018-11-09 16:35:55

标签: angular

如何引用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"}

输出将具有打开和关闭以及自定义的平均值

0 个答案:

没有答案