单击添加按钮后,我试图禁用该按钮。为简单起见,我不会仅添加导致问题的代码的详细信息。
<div *ngFor="let n of records">
<span>{{n.name}}</span>
<span>{{n.location}}</span>
<button (click)="addtomainrecord(n)" [disabled]="disablebutton">add</button>
</div>
在我的组件中,我已经声明
disablebutton:boolean=false;
//later in my code
addtomainrecord(record) {
this.disablebutton=true;
//rest of the code follows
}
我面临的问题是,一旦我第一次单击添加按钮,所有按钮都被禁用,而我只想禁用我刚刚单击的行按钮。
如何修复?