我正在填充具有多个值的下拉列表,例如productId,productName,skuId,Sku,Category Id。并显示带有下拉菜单,并显示为productName。
从Webapi到下拉列表的数据绑定。
在ts文件中
this.productData = response.result;
<select id="prodcode" class="form-control" formControlName="prodCode" required>
<option [value]="''">Product Code</option>
<option [ngValue]="product" *ngFor="let product of productData">
{{product.productName}}
</option>
</select>
听到我可以从类似产品的ng值获得产品详细信息
productName,skuId,Sku,类别ID。
表单编辑时无法从数据表填充下拉列表中的选定项目。我这样写
this.productForm.reset({
prodCode: row.ProductId,
ty: row.Quantity,
)};
因此,如何填充所选项目让我知道
如果row
是product
,则应将其设置为prodCode
。
this.productForm.reset({
prodCode: row,
ty: row.Quantity,
)};
而且我认为该变量的名称应更改为类似product
的名称。