我在角4素材表格单元格中有一个按钮,我只想在桌面上悬停时才会出现:
<md-cell *cdkCellDef="let row" contenteditable='false' >
<div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
<button md-icon-button><md-icon (click)="row.editorEnabled=true;" mdTooltip="Edit">mode_edit</md-icon></button>
</div>
</md-cell>
我如何实现这一目标?
更新: 整个代码:
<md-cell *cdkCellDef="let row" contenteditable='false' >
<div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
<button md-icon-button><md-icon (click)="row.editorEnabled=true;" class="editButton" mdTooltip="Edit">mode_edit</md-icon></button>
</div>
<div *ngIf="row.editorEnabled" >
<md-input-container><input mdInput [(ngModel)]="row.goalStatusName" #goalName></md-input-container>
<button md-icon-button>
<md-icon (click)="modifyGoal(row.goalStatusId,row.goalStatusName)" mdTooltip="Save" style="color:green;font:bold;" >done</md-icon>
</button>
<button md-icon-button>
<md-icon (click)="row.editorEnabled=false" mdTooltip="Cancel" style="color:red;font:bold;" >clear</md-icon>
</button>
</div>
</md-cell>
答案 0 :(得分:3)
button{ display:none}
md-cell:hover{
button{
display:block
}
}
答案 1 :(得分:2)
.editButton{ visibility: hidden}
md-cell:hover .editButton{
visibility: visible;
}
这很有用!