2

我有一个表的数据集:

在此处输入图像描述

我正在尝试将选择控件填充为带有结果的 html 表的一部分。

这就是我想要做的:

<ng-container matColumnDef="PricingTemplatesList">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Margin Template</th>
            <td mat-cell *matCellDef="let customer">
                <select id="pricingtemplates">
                    <option [ngValue]="pricingTemplate.Oid" *ngFor="let pricingTemplate of customer.PricingTemplatesList">{{pricingTemplate.Name}}</option>
                </select>
            </td>
        </ng-container>

我得到的结果是空白选择控件。

这是列表项的样子:

在此处输入图像描述

我什至在尝试使用此 {{customer.PricingTemplatesList.length}} 来查看项目是否存在,但我得到了未定义,尽管在执行 console.log(customer) 时,如您所见,我能够看到数据。

我需要做什么具体的事情吗?

4

1 回答 1

1

更正您的代码。使用下面的代码。

<ng-container matColumnDef="PricingTemplatesList">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Margin Template</th>
            <td mat-cell *matCellDef="let customer">
                <select id="pricingtemplates">
                    <option [ngValue]="pricingTemplate.Oid" *ngFor="let pricingTemplate of customer.pricingTemplatesList">{{pricingTemplate.name}}</option>
                </select>
            </td>
        </ng-container>

将 priceTemplate.Name 替换为 priceTemplate.name 。

并且还替换*ngFor customer.PricingTemplatesListcustomer.pricingTemplatesList(大写 P 到小写 P)。

于 2019-08-28T08:39:02.707 回答