在我的组件中,我从静止中得到响应,但在下拉菜单中无法填充相同的响应。
组件:
jobTitleList() {
this.jobList = this.getJobList().then((result) => {
this.jobList = result;
console.log('result is : ', this.jobList );
});
}
在控制台上我得到:结果是: ["Software Developer","Support Engineer"]
html选择/下拉:
<select (focus)="jobTitleList()">
<option *ngFor="let jobTitle of jobList" value="">{{jobTitle}}</option>
</select>
我在屏幕上获得空的选择框。请帮忙。我关注了许多帖子,但没有帮助。预先感谢。
job: IJob;
jobList: IJob[];
jobTitleList() {
this.getJobList().then(result => {
this.jobList = result;
});
}
<select [(ngModel)]="job" (focus)="jobTitleList()">
<option *ngFor="let j of jobList" [value]="j">{{ j }}</option>
</select>