加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – ng-bootstrap typeahead TypeError:Object(…)不是

发布时间:2020-12-17 17:52:17 所属栏目:安全 来源:网络整理
导读:我想在angular5应用程序中使用角度bootstrap typeahead linkToTypeahead. 但我不断收到以下错误: ERROR TypeError: Object(...) is not a functionat new NgbTypeahead (typeahead.js:52)at createClass (core.js:12449)at createDirectiveInstance (core.j
我想在angular5应用程序中使用角度bootstrap typeahead linkToTypeahead.
但我不断收到以下错误:

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”:“ng”,
????“开始”:“ng serve”,
????“build”:“ng build –prod”,
????“测试”:“ng测试”,
????“lint”:“ng lint”,
????“e2e”:“ng e2e”
??},
??“私人”:是的,
??“依赖”:{
????“@ angular / animations”:“^ 5.2.0”,
????“@ angular / common”:“^ 5.2.0”,
????“@ angular / compiler”:“^ 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”,
????“core-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”,
????“茉莉核心”:“~2.8.0”,
????“jasmine-spec-reporter”:“~4.2.1”,
????“业力”:“~2.0.0”,
????“karma-chrome-launcher”:“~2.2.0”,
????“karma-coverage-istanbul-reporter”:“^ 1.2.1”,
????“karma-jasmine”:“~1.1.0”,
????“karma-jasmine-html-reporter”:“^ 0.2.2”,
????“量角器”:“~5.1.2”,
????“ts-node”:“~4.1.0”,
????“tslint”:“~5.9.1”,
????“打字稿”:“~2.5.3”
??}
}

到目前为止我尝试了什么:

>用npm重新安装node_modules – 没有帮助
>使用角度CLI开始了一个全新的项目并在那里试用了代码 – 没有帮助.

任何帮助是极大的赞赏!

解决方法

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

所以package.json文件:

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

感谢JB Nizet和Niladri的快速解答

编辑:另外,正如@Niladri在评论中所说,你需要为你想要使用的模块使用forRoot().这是针对Angular 5的official documentation of version 1.1,这里说的是,但更新版本的角度曲线的新文档并未说明,因为它已被更改.所以记住这一点!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读