【发布时间】:2018-04-15 15:45:18
【问题描述】:
我需要为选择 UI 元素提供动态选项,我有一个方法可以根据输入返回可观察对象
TypeScript(组件类)
getCars(type : string, engine : string) : Observable<Cars>{
return this.carService.getCars(type,engine);
}
在 HTML 中,我让我的元素为数据调用此方法
Html(模板文件)
<ng-select [items]="getCars(type,engine) | async"
bindLabel="value"
bindValue="id"
</ng-select>
但这会导致服务被无限调用。我不想使用 ngOnInit,因为我需要动态分配 observable
【问题讨论】:
标签: angular bootstrap-4 angular-bootstrap angular-pipe