我正在尝试运行我的前端应用程序(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.0
https://github.com/valor-software/ngx-bootstrap/issues/3024
...感谢任何帮助
答案 0 :(得分:6)
从Angular 4.x.x升级到5.x.x时遇到此错误。原始代码是:
<template let-item>
</template>
这在Angular 4中运行良好,但在5中失败。只需使用ng-template
正常工作(不需要安装软件包,不需要缓存清理):
<ng-template let-item>
</ng-template>
答案 1 :(得分:5)
v2 +中没有<template>
个标签,请干净安装,
并检查你是否有ngx-bootstrap v2 +
检查包锁是否存在
答案 2 :(得分:3)
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
答案 3 :(得分:0)
它也面临着同样的问题。通过问题发现我创建的数组是
<ng-template ngFor [ngForOf]="names" let-name="$implicit" let-i="index">
<div><span>{{i+1}}</span> <span> {{name.name}}</span></div>
</ng-template>
like:-
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'}];
将类型指定为数组
答案 4 :(得分:0)
只需搜索
<template
并替换为<ng-template
</template>
并替换为</ng-template>
答案 5 :(得分:0)
您未在html文件中使用ng-template标记,但已将ngx模块导入到app.model.ts中 然后这会来。删除您的app.model导入语句并生成并检查。
谢谢。
答案 6 :(得分:-1)
我遇到了同样的问题,并在我的html文件中将<template>
标记替换为<ng-template>
我解决了这个问题。