html - 单击时更改图标
问题描述
单击下载文件时,我尝试设置微调器。但是,微调器会加载表格行中所有下载的文件,而不仅仅是单击的文件。
HTML
<td class="text-center px-1">
<a class="text-dark" title="Download document" style="cursor: pointer"
(click)="download(documentFiles.id, documentFiles.attachedName)">
<i *ngIf="!isLoading" class="far fa-file-pdf"></i>
<i *ngIf="isLoading" class="fas fa-spinner fa-spin" style= color:#572364></i>
</a>
</td>
下面是ts中下载方法的代码
下载.ts
download(id: number, attachedName: string)
{
this.isLoading = true;
this.newCustomerDocumentService.download(id, attachedName);
setTimeout(() => {
this.isLoading = false;
}, 4000);
}
解决方案
loadingDocument: string;
在您的组件中定义。
而不是this.isLoading = true;
,尝试this.loadingDocument = id
;
并替换this.isLoading = false;
为this.loadingDocument = null
并替换*ngIf="!isLoading"
为*ngIf="documentFiles.id === loadingDocument"
推荐阅读
- r - 在 Shiny 中获取用户输入(选择)后读取文件
- python - 如何使 JSON 文件自动更新?
- proxy - 您如何在 squid 代理中轮换代理/具有动态逻辑?
- python - 词干并将输出保存到文本文件
- sql - 具有访问权限从以前记录中的一个字段中检索多个值,以便在新记录中的不同字段中使用
- anaconda3 - /anaconda3/lib/python3.7/site-packages/ 中缺少 gast-0.4.0
- javascript - 使用@material-ui/lab 的DataGrid 组件,如何访问当前的活动过滤器?
- java - 如何使用 JavaFX 创建一个 nonogram 板
- javascript - 我需要使用绑定调用 window.requestAnimationFrame
- python - Groupby 带有列的掩码