html代码
<td >
<input type="text" class="form-control" value="create.qty[i]" (mouseenter)="toggle()" (mouseleave)="toggle()" name="qty" [(ngModel)]="this.create.qty[i]" #qty="ngModel" (change)="onqtyadd($event.target.value,i)" >
<div *ngIf="show">
<div *ngIf="show" style="border-radius: 6px;z-index: 8;position: absolute; background-color:black;height: 15%;padding-left:10px;color:white; width: 5%;"><p>{{qtyhover[i]}}</p></div>
</div>
</td>
我只想显示所选字段,但它会在动态表的每个字段中显示悬停
答案 0 :(得分:0)
使用boolean
属性代替number
使用show:number
并在show
和html中将索引(当前)设置为mouseenter/leave
,并在html中询问show
== {index
在HTML中:
(您不必ngIf
只问两次div
)
<input type="text" class="form-control" (mouseenter)="show=i" (mouseleave)="show=0">
<div *ngIf="show==1">
<div>your tooltip 1 </div>
</div>
查看示例:https://stackblitz.com/edit/hello-angular-6-eu5ecu?file=src/app/app.component.html