gpt4 book ai didi

html - 当我单击编辑按钮时,我所有的表值都更改为输入框?

转载 作者:搜寻专家 更新时间:2023-10-30 21:52:03 24 4
gpt4 key购买 nike

我的 HTML 包含 ng for 并且我已经获取了索引值并使用索引值我可以将我的值放入输入框。但是我的所有表列表都显示相同的值并且输入框打开。

<tr *ngFor="let item of items; let i=index">
<td><input type="checkbox" /></td>
<td>
<!-- {{ item.itemName }} -->
<span *ngIf="!myvar">{{ item.itemName }}</span>
<span *ngIf="myvar"><input type="text" [(ngModel)]="editUpdate.itemName" name="update.name" (keyup.enter)="UpdateItem()" (keyup.escape)="cancelEditingTodo()"></span>
</td>
<td>
<!-- {{ item.itemType }} -->
<span *ngIf="!myvar">{{ item.itemType }}</span>
<span *ngIf="myvar"><input type="text" [(ngModel)]="editUpdate.itemType" name="update.name" (keyup.enter)="UpdateItem()" (keyup.escape)="cancelEditingTodo()"></span>
</td>
<td>
<!-- {{ item.itemDescription }} -->
<span *ngIf="!myvar">{{ item.itemDescription }}</span>
<span *ngIf="myvar"><input type="text" [(ngModel)]="editUpdate.itemDescription" name="update.name" (keyup.enter)="UpdateItem()" (keyup.escape)="cancelEditingTodo()"></span>
</td>
<td>
<!-- {{ item.itemCurrentPrice }} -->
<span *ngIf="!myvar">{{ item.itemCurrentPrice }}</span>
<span *ngIf="myvar"><input type="text" [(ngModel)]="editUpdate.itemCurrentPrice" name="update.name" (keyup.enter)="UpdateItem()" (keyup.escape)="cancelEditingTodo()"></span>
</td>
<td><i class="fa fa-pencil" (click)="editItem(i)" aria-hidden="true"></i></td>
<td><i class="fa fa-trash" (click)="deleteItem(i)" aria-hidden="true"></i></td>
</tr>

我的ts文件是

editItem(i: number) {
this.myvar=true;
this.index=i;
this.editUpdate=this.items[this.index];
console.log("edit", this.editUpdate);
}

最佳答案

*ngIf= 表达式更改为

 *ngIf="i !== index"
*ngIf="i === index"

关于html - 当我单击编辑按钮时,我所有的表值都更改为输入框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42270608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com