現在の入力テキストを含むng-bootstrapのタイプヘッドで、フォーム・アレイ索引をgetCities関数に渡す方法。考慮するは、フォームの配列のインデックスです。角度2 ngのブートストラップ・タイプヘッドが追加のパラメーターを渡す
address.component.html
<input name="city" type="text" id="city" formControlName="city" [ngbTypeahead]="getCities">
address.component.ts
getCities = (text$: Observable<string>) =>
text$
.debounceTime(300)
.distinctUntilChanged()
.switchMap(query =>
query.length < 2 ? [] : this.apiService.getCities(query).catch(() => {
return Observable.of([]);
});)
現在のドキュメントのhttps://ng-bootstrap.github.io/#/components/typeahead/examples – Eliseo