的评论由David Aguirre提出这是一个依赖性问题,但似乎至少部分归因于ng-bootstrap版本。
我有这个同样的问题,发现我的NG-引导的版本是1.0.0-alpha.24,但在https://ng-bootstrap.github.io/app/components/tabset/demos/basic/plnkr.html的例子在config.js行是'@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/[email protected]/bundles/ng-bootstrap.js'
当我降低了该版本数字为1.0.0-alpha.24我得到了下面的一堆错误消息。
焦仲卿到1.0.0-alpha.28的变化曾在我们的网站上的代码的版本,但在VCCode开发环境的代码,我发现,只要改变<template>
到<ng-template>
和
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.24",
中的package.json到
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.28",
是不够的,解决这个问题,但创建一个新的CLI实例解决了这一问题,所以必须是我没找到一些其他的依赖性。
在https://ng-bootstrap.github.io/app/components/tabset/demos/basic/plnkr.html与1.0.0-alpha.24的警告是:
Template parse warnings:
The <template> element is deprecated. Use <ng-template> instead ("[WARNING ->]<template ngFor [ngForOf]="parts" let-part let-isOdd="odd"><span *ngIf="isOdd" class="{{highlightClas"): ng:///NgbTypeaheadModule/[email protected]:0
这是误解,因为代码使用<ng-template>
,而不是权利的警告<template>
元素。
错误消息的第一行是:
ERROR TypeError: Cannot read property 'templateRef' of undefined
ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 3, nodeDef: Object, elDef: Object, elView: Object}
Unhandled Promise rejection: Cannot read property 'templateRef' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'templateRef' of undefined
Error: Uncaught (in promise): TypeError: Cannot read property 'templateRef' of undefined
希望当其他人得到这些信息,他们会发现这个线程。
如果警告和错误信息没有那么具有误导性和不明确,这将会有所帮助。
听起来像一个依赖性错误。要么你错过了从模块导入,或者你需要更新你的Angular版本。 –