Html 选择单元格时,如何获取表格标题的值?

Html 选择单元格时,如何获取表格标题的值?,html,css,angular,typescript,Html,Css,Angular,Typescript,我正在申请预订房间,我使用Angular 2。我想在我的表格中选择单元格并获取垂直和水平标题的值,如“Room 1”和“9:00”。我正在从服务器获取表头的数据。这是我的html代码: <div class="table"> <table class="schedule-table" *ngIf="titles && titles.length && intervals && intervals.length">

我正在申请预订房间,我使用Angular 2。我想在我的表格中选择单元格并获取垂直和水平标题的值,如“Room 1”和“9:00”。我正在从服务器获取表头的数据。这是我的html代码:

<div class="table">
<table class="schedule-table" *ngIf="titles && titles.length && intervals && intervals.length">
        <tr>
            <th class="vertical-header-cell"></th>
            <th class="horizontal-header-cell" *ngFor="let title of titles">{{ title }}</th>
        </tr>
        <tr *ngFor="let interval of intervals">
            <th class="vertical-header-cell">{{ interval }}</th>
            <th class="body-cell" *ngFor="let title of titles"></th>
        </tr>
</table>

使用
单击功能

<th class="horizontal-header-cell" *ngFor="let title of titles" (click)="clickHeader(title,intervals)" >{{ title }}</th>

clickHeader(title: any, intervals: any){
   console.log(title + intervals)
}
{{title}
单击标题(标题:任意,间隔:任意){
控制台日志(标题+间隔)
}

谢谢,但使用此功能我只能获得标题。我想得到“title”和“interval”,就像一个单元格的坐标。是的,它击中了我)谢谢)
<th class="horizontal-header-cell" *ngFor="let title of titles" (click)="clickHeader(title,intervals)" >{{ title }}</th>

clickHeader(title: any, intervals: any){
   console.log(title + intervals)
}