3 回答
TA贡献1813条经验 获得超2个赞
服务
listNama() {
return this.http.get(this.BaseURL + 'welcome/getnama')
}
然后在你的组件中订阅它
/decalre a variable
NameList:any[]=[];
/ replace service with your servicename
this.service.function.subscribe(arg => this.NameList = arg);
并在模板中
<select [(ngModel)]="selected" (change)="onChange($event)">
<option [label] ="nama" *ngFor="let item of NameList" [selected]="selected"
[value]="nama">{{nama}}
</option>
</select>
TA贡献1810条经验 获得超5个赞
Ts
NameList:any[]=[];
listNama() {
return this.http.get(this.BaseURL + 'welcome/getnama')
.pipe(map(response => {
this.NameList= response.Output;
}));
}
html
<select [(ngModel)]="selected" (change)="onChange($event)">
<option [label] ="nama" *ngFor="let item of NameList" [selected]="selected" [value]="nama">
{{nama}}
</option>
</select>
添加回答
举报