title: Angular 2 ng bootstrap typehead pass additional parameter
body: <p>How to pass form array index to getCities function in ng-bootstrap typehead including current input text. Consider <strong>3</strong> is form array index.</p>
  
  <p><strong>address.component.html</strong></p>
  
  <pre><code>&lt;input name="city" type="text" id="city" formControlName="city" [ngbTypeahead]="getCities"&gt;
  </code></pre>
  
  <p><strong>address.component.ts</strong></p>
  
  <pre><code>getCities = (text$: Observable&lt;string&gt;) =&gt;
      text$
        .debounceTime(300)
        .distinctUntilChanged()
        .switchMap(query =&gt;
          query.length &lt; 2 ? [] : this.apiService.getCities(query).catch(() =&gt; {
              return Observable.of([]);
          });)
  </code></pre>