我想在下拉列表中显示“内阁”数组中的项目。我已经尝试了下面的代码,但它不起作用。请帮忙。
组件.ts 文件:
getProductDetail(id: string) {
const x = this.productService.getProductById(id);
x.snapshotChanges().subscribe(
(product) => {
const y = product.payload.toJSON() as Product;
y.$key = id;
this.cabinet = y['cabinet'];
console.log("Cabinets",this.cabinet);
return this.cabinet;
}
组件.html 文件
<div>
Select Cabinet
<select
[(ngModel)]="selectedCabinetType"
>
<option *ngFor="let item of cabinet">
{{ item }}
</option>
</select>
</div>