我注意到,在触发的对话框关闭后,该按钮会获得以cdk为重点的类和cdk-program-focused.如果我点击任何地方效果消失.
app.component.html [片段]
<mat-cell *matCellDef="let element"> <span matTooltip="Delete" matTooltipPosition="right"> <button mat-icon-button color="warn" (click)="openDeleteAssociationDialog()"> <mat-icon>delete</mat-icon> </button> </span> </mat-cell>
解决方法
>在HTML中添加一些id的按钮.在我的情况下,它是#changeButton:
<button #changeButton mat-icon-button (click)="changeItem(element)" disableRipple> <mat-icon>edit</mat-icon> </button>
>在.ts文件中导入ViewChild和ElementRef:
{ ViewChild,ElementRef } from '@angular/core';
@ViewChild('changeButton') private changeButton: ElementRef;
>订阅对话框的afterClose()事件并删除以cdk-program为重点的css类:
dialogRef.afterClosed().subscribe(result => { this.changeButton['_elementRef'].nativeElement .classList.remove('cdk-program-focused'); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。