【发布时间】:2021-02-05 00:28:54
【问题描述】:
我有一个下拉列表,可以在其中获取一些 json 数据。我通过获取所有 API 获取数据。所以我没有硬编码任何数据。我是在角度做这个
<td>
<mat-form-field>
<mat-label>Customer</mat-label>
<mat-select formControlName="custom">
<mat-option *ngFor="let customer of customerList" [value]="customer.id">
{{customer.name}}
</mat-option>
</mat-select>
</mat-form-field>
</td>
所以这里我有一个名为 customerList 的列表,里面的数据是 json 格式。所以我必须在下拉列表中显示名称字段并将 id 传递给后端。所以我的任务是在这个下拉列表中进行自动完成搜索
【问题讨论】:
-
你可以在这里添加你的示例customerList、ts文件和html文件吗?
-
[{"id":1,"name": "kumar"},{"id":2, "name" "mukesh"}]。我无法添加 ts 文件,因为它太大而无法理解
标签: angular typescript autocomplete angular-material angular-forms