ngbTypeahead不适用于Angular 6和ng-bootstrap

时间:2018-10-16 16:51:43

标签: angular ng-bootstrap rxjs6

我正在尝试在基本的Angular 6应用程序上使用ngbTypeahead。应用程序中没有很多其他依赖项。我不断收到以下方法签名未找到错误...

ERROR TypeError: Object(...)(...) is not a function
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.pipe (Observable.js:91)

如果我遵循这一行,它将最终到达该代码,即它正在寻找的方法。

return pipeFromArray(operations)(this);

这里是进口

import { Component, OnInit } from '@angular/core';
import {Observable} from 'rxjs';
import {debounceTime, map} from 'rxjs/operators';

这是我的package.json

{
  "name": "myapp",
  "version": "1.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@ng-bootstrap/ng-bootstrap": "^3.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.2",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

1 个答案:

答案 0 :(得分:0)

我有同样的问题,这仅仅是因为过滤器代码错误。确保在[ngbTypeahead]上调用的过滤器方法确实返回了Observable。就我而言,我替换了代码,但未返回任何内容导致未定义的问题。

示例: search = (text$: Observable<string>) => text$ .debounceTime(200) .distinctUntilChanged() .map(term => term.length < 2 ? [] : states.filter(v => new RegExp(term, 'gi').test(v)).splice(0, 10));

There is a plunker with working code here: