Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度2表格行悬停,用于显示悬停行上的按钮_Angular_Html Table_Row - Fatal编程技术网

Angular 角度2表格行悬停,用于显示悬停行上的按钮

Angular 角度2表格行悬停,用于显示悬停行上的按钮,angular,html-table,row,Angular,Html Table,Row,我被困在鼠标悬停事件中,无法在行上显示隐藏的编辑按钮。使用此方法,它将显示每行上的所有编辑按钮。我在AngularJs 1x中实现了这一点,只是因为ng mouseenter在每个tr元素内部设置了一个范围。但是,角度2的情况并非如此 <table> <tr *ngFor="let ob of objects" on-mouseover="rowHovered=true" on-mouseleave="rowHovered=false"> <td&g

我被困在鼠标悬停事件中,无法在行上显示隐藏的编辑按钮。使用此方法,它将显示每行上的所有编辑按钮。我在AngularJs 1x中实现了这一点,只是因为ng mouseenter在每个tr元素内部设置了一个范围。但是,角度2的情况并非如此

<table>
   <tr *ngFor="let ob of objects" on-mouseover="rowHovered=true" on-mouseleave="rowHovered=false">
     <td>{{ob.name}}</td>
     <td>
        <button *ngIf="rowHovered==true">edit</button>
     </td>
  </tr>
</table>

{{ob.name}
编辑

尝试存储悬停索引:

<table on-mouseleave="hoveredIndex=null">
   <tr *ngFor="let ob of objects; let index=index" on-mouseover="hoveredIndex=index">
     <td>{{ob.name}}</td>
     <td>
        <button *ngIf="index==hoveredIndex">edit</button>
     </td>
  </tr>
</table>

{{ob.name}
编辑

我也不确定鼠标上方的
语法。考虑使用角事件绑定而不是代码>(MouSeOver)=“HoVeDealEdv= index”< /C> >谢谢您的快速响应。对于这种情况,我喜欢on mouseover方法,因为所有的逻辑都在同一页上,不需要深入TS文件;它可以用同样的方法计算表达式