我正在尝试从rest api获取数据以显示在下拉列表中。我可以调用rest api,但它正在获取数据,但不会在html中显示下拉列表。以下是我的html代码
<select>
<option *ngFor="let discountlist of discountlists" [value]="discountlist.id{{discountlist.discount_code}}</option>
</select>
下面是我在ngOnInit函数中调用的组件类,
this.autopostService.getcarDiscountSchemesList(this.myDate).subscribe(
(data: Autodiscount) => this.discountlists = data,
error => this.error = error
);
尝试这样写:
<option *ngFor="let discountlist of discountlists">{{discountlist.id}}
{{discountlist.discount_code}}</option>