页面上的每个按钮都会激活“加载微调器" [英] Loading Spinner activates on every button on the page
本文介绍了页面上的每个按钮都会激活“加载微调器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将加载微调器集成到按钮中.这也很好.问题是:如果我单击一个按钮,则微调器将响应所有其他按钮.
I'm trying to integrate a loading spinner into a button. This also works very well. The problem: If I click on a button, the spinner will respond to every additional button.
我该如何纠正?
我的代码:
<button ion-button block (click)="loading = true">
<ion-spinner class="whiteSpinner" item-left *ngIf="loading" name="bubbles"></ion-spinner>
Buy now - 1,49€
</button>
其他按钮都一样...
The other buttons like the same...
图片向您展示我的意思
推荐答案
如果您有一堆动态按钮,则可以为其添加唯一的ID.即使使用例如*ngFor
来生成所有按钮,它们也将具有与本例中的myButton
不同的唯一ID.
If you have bunch of dynamic buttons you can add unique id to them. Even if you use for example *ngFor
to generate all buttons they will have unique ids different from in this case myButton
.
<button #myButton ion-button block (click)="myButton.loading = true">
<ion-spinner class="whiteSpinner" item-left *ngIf="myButton.loading" name="bubbles"></ion-spinner>
Buy now - 1,49€
</button>
这篇关于页面上的每个按钮都会激活“加载微调器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文