<td> <nz-select nzPlaceHolder="请选择采购明细" class="form-control" formControlName="buyOrderItem"> <nz-option *ngFor="let buyOrderItemOption of currentBuyOrderItems" [nzValue]="buyOrderItemOption" [nzLabel]="buyOrderItemOption.item?.serialNo + ' / ' + buyOrderItemOption.quantity" > </nz-option> </nz-select> </td> <td> <input nz-input type="number" class="form-control" formControlName="receiptCount" /> </td> 以上是angular的前端代码的两个td 现在想要将第一个td中的下拉框选中的单号对应的该单的数量自动填入第二td中 应该怎么编写更改这段代码
时间: 2024-02-10 07:14:36 浏览: 121
Strust2的if-else <tr></tr>用法
你可以在第一个td中的下拉框的change事件中,获取选中的采购明细的数量,并将其填入第二个td中的input中。具体代码如下:
```html
<td>
<nz-select nzPlaceHolder="请选择采购明细" class="form-control" formControlName="buyOrderItem" (ngModelChange)="onBuyOrderItemChange($event)">
<nz-option *ngFor="let buyOrderItemOption of currentBuyOrderItems" [nzValue]="buyOrderItemOption" [nzLabel]="buyOrderItemOption.item?.serialNo + ' / ' + buyOrderItemOption.quantity"></nz-option>
</nz-select>
</td>
<td>
<input nz-input type="number" class="form-control" formControlName="receiptCount" [value]="receiptCount" />
</td>
```
```typescript
// 在组件中添加以下代码
receiptCount: number;
onBuyOrderItemChange(buyOrderItem: any) {
this.receiptCount = buyOrderItem.quantity;
}
```
这样,当你选中第一个td中的下拉框选项时,第二个td中的input就会自动填入选中采购明细的数量。
阅读全文