首页 > 解决方案 > ngbTypeahead 抛出异常

问题描述

当我尝试使用 ng-bootstrap (2.0.0) typeahead 组件时,我在库本身内部遇到了故障。我正在使用这个版本,因为我不能只升级到 Angular 6。这是我遇到的错误。

错误 TypeError: Object(...) is not a function
at new NgbTypeahead (typeahead.js:54)
at createClass (core.js:10382)
...
at Object.debugCreateEmbeddedView [as createEmbeddedView] (core.js:12294)

我像这样设置HTML:

<ng-template #listSelectionFormatter let-r="result">
    <span (click)="onWorkerSelected(r)">{{r.wwid}} - {{r.fullName}}</span>
</ng-template>

<div class="form-group">
    <label *ngIf="labelText" class="col-form-label" for="wwid">{{ labelText }}</label>
    <input id="wwid" name="wwid" type="text"
           class="form-control"
           placeholder="Search by WWID, IDSID, Name or Email"
           [ngModel]="ngModel"
           [ngbTypeahead]="search"
           [inputFormatter]="selectedResultsFormatter"
           [resultTemplate]="listSelectionFormatter"
          />
    <span *ngIf="searching">searching&hellip;</span>
    <div class="invalid-feedback" *ngIf="searchFailed">Lookup failed.</div>
</div>

标签: angular5ng-bootstrap

解决方案


推荐阅读