gpt4 book ai didi

angular - ng-bootstrap typeahead TypeError : Object(. ..) 不是函数

转载 作者:太空狗 更新时间:2023-10-29 17:24:11 24 4
gpt4 key购买 nike

我想使用 angular bootstrap typeahead linkToTypeahead在 angular5 应用程序中。但我不断收到以下错误:

ERROR TypeError: Object(...) is not a function
at new NgbTypeahead (typeahead.js:52)
at createClass (core.js:12449)
at createDirectiveInstance (core.js:12284)
at createViewNodes (core.js:13742)
at callViewAction (core.js:14176)
at execComponentViewsAction (core.js:14085)
at createViewNodes (core.js:13770)
at callViewAction (core.js:14176)
at execComponentViewsAction (core.js:14085)
at createViewNodes (core.js:13770)

还有:

ERROR TypeError: Cannot read property 'instance' of undefined
at nodeValue (core.js:11753)
at Object.eval [as handleEvent] (NgbdTypeaheadBasic.html:9)
at handleEvent (core.js:13547)
at callWithDebugContext (core.js:15056)
at Object.debugHandleEvent [as handleEvent] (core.js:14643)
at dispatchEvent (core.js:9962)
at eval (core.js:10587)
at HTMLDocument.eval (platform-browser.js:2628)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4740)

我从网站 link 复制了 Simple Typeahead 代码.

我的 package.json 文件:

{
“名称”:“提前测试”,
“版本”:“0.0.0”,
“许可证”:“麻省理工学院”,
“脚本”:{
“吴”:“吴”,
“开始”:“服务”,
“构建”:“ng构建--prod”,
“测试”:“NG测试”,
“林特”:“吴林特”,
“e2e”:“ng e2e”
},
“私有(private)”:是的,
“依赖”:{
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/编译器": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-b​​rowser": "^5.2.0",
"@angular/platform-b​​rowser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^2.0.0-alpha.0",
“ Bootstrap ”:“^4.1.0”,
“核心 js”:“^2.4.1”,
"rxjs": "^5.5.6",
“zone.js”:“^0.8.19”
},
“devDependencies”:{
"@angular/cli": "~1.7.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/ Jasmine ": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
“codelyzer”:“^ 4.0.1”,
“ Jasmine 核心”:“〜2.8.0”,
"jasmine-spec-reporter": "~4.2.1",
“业力”:“〜2.0.0”,
“业力 Chrome 发射器”:“〜2.2.0”,
“业力报道- Istanbul 尔记者”:“^1.2.1”,
“业力 Jasmine ”:“~1.1.0”,
"karma-jasmine-html-reporter": "^0.2.2",
“Protractor ”:“~5.1.2”,
“ts-节点”:“〜4.1.0”,
“tslint”:“~5.9.1”,
“ typescript ”:“〜2.5.3”
}
}
到目前为止我尝试了什么:

  1. 用 npm 重新安装了 node_modules -- 没有帮助
  2. 使用 Angular CLI 启动了一个全新的项目并尝试了那里的代码——没有帮助。

非常感谢任何帮助!

最佳答案

所以我的问题通过安装稳定版本的 ng-bootstrap 解决了:

所以 package.json 文件:

`dependencies
....
"@ng-bootstrap/ng-bootstrap": "^1.1.1",
....
dependencies`

感谢 JB Nizet 和 Niladri 的快速回答


编辑:此外,正如@Niladri 在评论中所说,您需要对要使用的模块使用 forRoot() 。这是 official documentation of version 1.1这是针对 Angular 5 的,这里说了,但是新版本的 angular 的新文档没有这么说,因为它已经改变了。所以请记住这一点!

关于angular - ng-bootstrap typeahead TypeError : Object(. ..) 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49816852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com