【发布时间】:2018-11-20 20:57:58
【问题描述】:
如何从下拉列表中显示实际选择的选项,并在拉伸列表后显示其他可用元素。现在我有一个只有可用元素的下拉列表,我可以选择元素。 HTML:
<div class="pb-1">
<label class="small">Car:</label>
<select formControlName="Car" class="form-control">
<option *ngFor="let x of cars" [ngValue]='x.id'>{{x.id}} : {{x.carName}}</option>
</select>
</div>
TypeScript:
export class PersonDetailsComponent implements OnInit {
cars : Car[];
.
.
.
populateCars()
{
this.personsService.getCars().subscribe(result => {
this.cars = result;
});
}
personsService:
getCars() :Observable<Car[]>
{
return this.http.get(this.apiUrl + 'AviableCars')
.map((result)=>result.json());
};
【问题讨论】:
标签: javascript angular typescript angular5 asp.net-core-webapi