angular - 为单击的元素显示多个加载指示器
问题描述
我有这个*ngFor
<div *ngFor="let notificacao of notificacoes; let i = index">
{{notificacao.marketplace}}
{{notificacao.data_entrada | date:'dd/MM/yyyy'}}
{{notificacao.data_entrada | date:'shortTime'}}
<h6><strong>{{notificacao.mensagem}}</strong>
<i *ngIf="loading && identificadorLoading == notificacao.identificador"></i>
<svg *ngIf="identificadorLoading !== notificacao.identificador || !loading" (click)="testaLoadingExclusao(notificacao.identificador, i)">
</svg>
</h6>
</div>
我的功能testaLoadingExclusao()
testaLoadingExclusao(identificador, index){
this.loading = true;
this.identificadorLoading = identificador
}
我怎样才能使加载显示在超过 1 个点击的元素中?
我现在拥有的:
解决方案
尝试使用这样的数组,而不是只跟踪一个加载指示器:
private identificadorLoading: string[] = [];
....
testaLoadingExclusao(identificador, index){
this.loading = true;
this.identificadorLoading.push(identificador);
}
在你的 html 中:
<div *ngFor="let notificacao of notificacoes; let i = index">
{{notificacao.marketplace}}
{{notificacao.data_entrada | date:'dd/MM/yyyy'}}
{{notificacao.data_entrada | date:'shortTime'}}
<h6><strong>{{notificacao.mensagem}}</strong>
<i *ngIf="loading && identificadorLoading.includes(notificacao.identificador)"></i>
<svg *ngIf="!identificadorLoading.includes(notificacao.identificador) || !loading" (click)="testaLoadingExclusao(notificacao.identificador, i)">
</svg>
</h6>
</div>
推荐阅读
- node.js - 执行图表生成时出现 0x03 错误:请检查您在 Highchart 中的输入数据
- ruby-on-rails - Rails:切换到 puma 以获取请求规格
- javascript - 通过将选项传递给模式,使所有字段或某些字段成为必需字段
- javascript - 如何将 unicode 十六进制值转换为 Javascript 中的字符串字符?
- node.js - App Engine Node.js 错误:排队的消息过多
- yocto - libiomp5.so 的多个 shlib 提供程序
- c++ - 构造函数委托与默认参数
- high-availability - 具有 2 个节点 proxmox 的 HA 集群
- spring-boot - 没有属性文件的 SpingBoot @Value
- typescript - Angular 动态表单控件