Как я могу добавить ссылку на возвращенные результаты typeahead - PullRequest
0 голосов
/ 05 ноября 2019

Я создал панель поиска и возвращаю результаты из моего mongodb. Я хочу показать выпадающий список найденных данных и сделать кликабельный каждый из них.

Я пытался создать в разделе результатов, но это не сработало. Я также пытался создать его и получить результаты внутри этого раздела, но он просто показал слово link.

\\ I tried this but it just returned the word r.link:

<ng-template #rt let-r="result" let-t="term">
  <a href='r.link'><ngb-highlight [result]="r.title" [term]="t"></ngb-highlight></a>
</ng-template>

\\ I also tried this but it broke it
<ng-template #rt let-r="result" let-t="term">
  <ngb-highlight [result]="<a href='r.link'>r.title</a>" [term]="t"></ngb-highlight>
</ng-template>
\\ I would like to add a link to this dropdown for each title.
\\ This is my html file

<ng-template #rt let-r="result" let-t="term">
  <ngb-highlight [result]="r.title" [term]="t"></ngb-highlight>
</ng-template>

<div class="row">
    <div class="col-xl-12">
      <div class="row">
        <div class="form-group col-md-12">
          <input id="search" name="search" [ngbTypeahead]="search" type="text" placeholder="Search for solutions..." class="form-control-search-bar form-control-underlined amcs-search" [resultTemplate]="rt" [inputFormatter]="title">
        </div>
      </div>
    </div>
</div>
\\ This is my search.component.ts


search = (text$: Observable<string>) =>
      text$.pipe(
        debounceTime(300),
        distinctUntilChanged(),
        tap(() => this.searching = true),
        switchMap(term =>
          this._service.search(term).pipe(
            tap((searchResults) => { this.searchFailed = false; }),
            catchError(() => {
              this.searchFailed = true;
              return of([]);
            }))
        ),
        tap(() => this.searching = false)
      )

      title = (x: {tag: string}) => x.tag;


Any help would be appreciated. Thank you
...