我有一个* ngFor,它给了我商品的特定商品列表,并且我点击了一个特定的按钮来选择它们。当我点击我的选择按钮时,它会暂时禁用该按钮,直到我从我的后端得到响应为止。当我从后端得到我的回应时,该按钮变为活动状态以取消选择该项目。[禁用] =“选择按钮”禁用所有按钮
我在这里面临的问题是,当我单击选择按钮时,它会暂时禁用列表中的所有按钮。但我想要的只是使点击按钮被禁用。
我的HTML代码片段:
<ion-card *ngFor="let list of list_Array;>
<ion-card-content >
<p style="color: #666; " [innerHTML]="list.item"></p>
</ion-card-content>
<button ion-button color="secondary" clear (click)="activeButton(list._id)" *ngIf="list.isAlreadyChosen==true" [disabled]="ChooseButton">
<div class="chosen"
ng-class="{'chosen': isChosen}">
<p >choose</p>
</div>
</button>
<button ion-button color="secondary" clear (click)="activeButton(list._id)" *ngIf="list.isAlreadyChosen==false" [disabled]="ChooseButton" >
<div class="choosen"
ng-class="{'chosen': isChosen}">
<p >choose</p>
</div>
</button>
</ion-card>
那么我怎么可能使它在我的类型脚本文件中为真或假, 目前我使用它像 activeButton = function(listId){ this。ChooseButton = true; 后,我有我的API调用的响应我让 this.ChooseButton =假 } – devanshsadhotra
它给我一个错误,如‘关于字符串'“无法创建属性’ChooseButton 58bfc0e3733305f5e” 这个字符串就是所选择项的ID – devanshsadhotra
@devanshsadhotra您必须传递(click)=“activeButton(list)”对象,而不是字符串。 –