【问题标题】:how to get multiple values from selected single item in angular 8如何从角度8中的选定单个项目中获取多个值
【发布时间】:2019-09-26 14:41:44
【问题描述】:

我正在使用多个值填充下拉列表,例如 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 [value]="product.productId"
             *ngFor="let product of productData">                                    
              {{product.productName}}</option>
 </select>

听说我只能通过 formcontrol 获取 productId。我需要在 ts 文件中获取所有铰孔数据,例如

productName,skuId,Sku,Category Id。

请帮帮我。

【问题讨论】:

    标签: bootstrap-4 angular7 dropdown asp.net-core-webapi


    【解决方案1】:

    通过将值与[ngValue] 绑定,您将拥有一个产品对象。

    <option [ngValue]="product" *ngFor="let product of productData">
      {{product.productName}}
    </option>
    

    【讨论】:

    • @user3257223 在TS文件中,你可以通过prodCode获取你在formControlName中命名的数据
    • zmag 如何在编辑模式下绑定下拉产品ID?我写得像..... this.productForm.reset({ prodCode: row.ProductId )};..听说无法获得该产品..
    猜你喜欢
    • 1970-01-01
    • 2010-10-31
    • 2021-01-08
    • 1970-01-01
    • 2020-04-09
    • 2020-02-14
    • 1970-01-01
    • 2021-12-05
    • 2019-01-22
    相关资源
    最近更新 更多