【发布时间】:2019-11-26 14:59:56
【问题描述】:
我尝试为表的 tr td 值编写点击事件。我已经生成了一个表并且我有 tableid。如果我点击第一列 td 值,我想显示警报。我们该怎么做?有什么解决方案吗?
请不要写任何内联 onclick 事件。我想写在 app.component.ts 文件中。
例子:
app.component.html:
<custom-table id="tableId">
<table>
<thead>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</thead>
<tr>
<td>123456</td> ---->If i click this i want to show alert with this value
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>253689</td>---->If i click this i want to show alert with this value
<td
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
<custom-table>
app.component.ts:
ngOnInit(){
???
}
【问题讨论】:
标签: angular6 angular7 angular8