【发布时间】:2021-07-28 01:38:49
【问题描述】:
我有一个这样的材料表行:
<ng-container matColumnDef="delete">
<mat-header-cell *matHeaderCellDef>Delete</mat-header-cell>
<mat-cell *matCellDef="let data">
<mat-spinner *ngIf="isDeleting" [diameter]="25" ></mat-spinner>
<button *ngIf="!isDeleting" mat-raised-button (click)="deleteRecord(data.id)">Delete</button>
</mat-cell>
</ng-container>
I want to make it so that when the button in the row is selected, the button goes away and the spinner shows up until the loading is completed.上面的代码使所有的按钮行消失并显示加载,我只想要被点击的行按钮。
【问题讨论】:
-
你有没有想过这个问题?尝试自己做类似的事情并遇到了这个
-
@Josh 没什么超级干净的,但您可以根据行的索引显示微调器。因此,如果选择了索引 5 行,则将
selectedButton = 5保存在某处并在每个按钮上添加一个条件,检查按钮索引是否与保存的索引匹配,然后显示微调器。 -
这是个好主意。我将看看是否可以向表正在迭代的对象添加一个道具,例如
loading或其他东西,并通过在单击时和整个代码中设置值来管理它。如果我不能解决这个问题,你的会很好。感谢您对一个相对较老的问题的快速响应!
标签: angular-material