非同期リストを使用ng-select
しています選択したオブジェクトをバインドする方法がわかりません
<ng-select formControlName="traLoiMaVanBan"
[items]="lstVanBanDen$ | async"
bindLabel="text"
bindValue="value"
[hideSelected]="true"
[loading]="documentloading"
[typeahead]="documentinput$"
[(ngModel)]="model.traLoiMaVanBan">
</ng-select>
TS コード:
documentloading: boolean = false;
lstVanBanDen$: Observable<any[]>;
documentinput$ = new Subject<string>();
private loadIncommingDocument(value:string) {
this.lstVanBanDen$ = concat(
of([]), // default items
this.documentinput$.pipe(
startWith(value),
debounceTime(200),
distinctUntilChanged(),
tap(() => this.documentloading = true),
switchMap(term => this._service.suggestIncommingDocument({ keyword: term }).pipe(
catchError(() => of([])), // empty list on error
tap(() => this.documentloading = false)
))
)
);
}
ngOnInit() {
this.createFormDocument();
this.loadIncommingDocument("");
this.getInfoOutDocument();
}
this._service.getInfoOutDocument(request).subscribe(data => {
this.model = data;
if (this.model.traLoiMaVanBan != null) {
this.loadIncommingDocument(data.traLoiVanBanInfo.text);
}
this.rebuildFormDocument();
});
data.traLoiVanBanInfo is an object like {value:1,text:"Something"}
ng-select で選択済みを設定するにはどうすればよいですかthis.model.traLoiMaVanBan = data.traLoiVanBanInfo.value