下拉列表未显示在数据库html上

问题描述 投票:0回答:1

我正在尝试从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
    );
angular angular7
1个回答
0
投票

尝试这样写:

<option *ngFor="let discountlist of discountlists">{{discountlist.id}} 
 {{discountlist.discount_code}}</option>
© www.soinside.com 2019 - 2024. All rights reserved.