"let-" 仅在 ng-template 元素上受支持

"let-" is only supported on ng-template elements

我正在尝试将我的前端应用程序 (Angular5.1.x) 添加到 运行 但由于模板解析错误它停止了:

"let-" is only supported on ng-template elements. ("
</thead>
<tbody>
<template ngFor [ngForOf]="rows" [ERROR ->]let-rowz="$implicit" let-    index="index">
<tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].sec"):     
ng:///DatepickerModule/DayPickerComponent.html@52:58
    at syntaxError (compiler.js:485)
    at TemplateParser.parse (compiler.js:24633)
    at JitCompiler._parseTemplate (compiler.js:34442)
    at JitCompiler._compileTemplate (compiler.js:34417)
    at compiler.js:34318
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (compiler.js:34318)
    at compiler.js:34188
    at Object.then (compiler.js:474)
    at JitCompiler._compileModuleAndComponents (compiler.js:34187)

我想我需要关注这个主题问题,说明我需要使用 ngx-bootrap@ngx-bootstrap@2.0.0-beta.8,但它不适用于那个或 v .2.0.0-rc.0

https://github.com/valor-software/ngx-bootstrap/issues/3024

...感谢任何帮助

v2+ 中没有 <template> 标签,请进行全新安装, 并检查你是否有 ngx-bootstrap v2+ 检查包锁(如果存在)

ngx-bootstrap 1.x.x 使用 <template>,已在 angular 5.x.x 中弃用。所以你必须升级到 ngx-bootstrap 2.X.X

执行以下操作升级

npm uninstall --save ngx-bootstrap
npm cache clean -f
npm install --save ngx-bootstrap

我在从 Angular 4.x.x 升级到 5.x.x 时遇到了这个错误。原始代码为:

<template let-item>

</template>

这在 Angular 4 中工作正常,但在 5 中失败。只需使用 ng-template 即可正常工作(不需要安装包,不需要清理缓存):

<ng-template let-item>

</ng-template>

我遇到了同样的问题,在我的 html 文件中用 <ng-template> 替换了 <template> 标签,我解决了这个问题。

它也面临同样的问题。通过问题发现我创建的数组是

<ng-template  ngFor [ngForOf]="names" let-name="$implicit" let-i="index">
  <div><span>{{i+1}}</span> <span> {{name.name}}</span></div>
</ng-template>

喜欢 :-

names= [{id:1,name:'shashikant'},{id:2,name:'Rakesh'},{id:3,name:'Umesh'}];

然后我替换为:-

names:Array<any>= [{id:1,name:'shashikant'},{id:2,name:'Rakesh'},{id:3,name:'Umesh'}];

指定数组类型

只需搜索所有

  1. <template 并替换为 <ng-template

  2. </template> 并替换为 </ng-template>

您没有在 html 文件中使用 ng-template 标签,但是您已经导入了 ngx 模块 app.model.ts 然后这会来。删除您的 app.model 导入语句并构建并检查。

谢谢。