如何在角度2中单击行时隐藏并显示另一个表格?

时间:2017-06-09 12:27:36

标签: angular

I want to do like this in angular 2

没有第三方库的任何建议。 我尝试使用下面的代码在我的表格中显示/隐藏<td>

在我的html中:

<tr *ngFor="let new of RESULTDATA;let i = index">
 <td ngIf="i==SelectedIndex"><input type="textbox"></td>

我想在我的表格中选择哪一行(不在旁边)显示几行。给我建议

1 个答案:

答案 0 :(得分:0)

Let's try this :

<tr *ngFor="let new of RESULTDATA; let i = index;">
    <span *ngIf="i === indexOfClickedRow">
        <td><button (click)="indexOfClickedRow = i">click me</button></td>
        <td><input type="text"/></td>
    </span>
</tr>

And don't forget to declare indexOfClickedRow in your component.

By doing this, clicking on a button will hide all the other rows.