首页 > 解决方案 > 更新 NgFor 表中的行

问题描述

我正在显示来自服务器的数据,在 ngFor 循环中,在表内,我希望能够随时更改或更新值,而不是在每一行旁边都有按钮,

或者无论如何切换按钮编辑以启用仅编辑一行?

例如这里

 <table>
        <tr *ngFor="let car of cars ;index as i ">
            <td>  
 <input type="text"   name="color"   [(ngModel)]="model.color" #color="ngModel" >
</td>
            <td>{{ car.brand }}</td>
            <td>{{ car.id }}</td>
        </tr>
    </table>

当我这样做时,我只需点击表格下方的按钮

 <button type="button" (click)="onUpdateCar()"> update </button>

标签: node.jsangularjsnpmnodesangular8

解决方案


推荐阅读