我正在将我的angular-cli项目从Angular-4迁移到Angular-5,但是面对这个错误,有人知道解决这个错误的方法吗?
Uncaught Error: Template parse errors:
"let-" is only supported on ng-template elements. ("
<template #tourStep [ERROR ->]let-step="step">
<p class="tour-step-content">{{step?.content}}</p>
<div class="tour-step"): ng:///TourNgBootstrapModule /TourStepTemplateComponent.html@1:24
at syntaxError (compiler.js:466)我试过安装ngx-bootstrap,但没有成功。谁知道修复这个错误的解决方案?
发布于 2018-02-23 18:07:36
经过很长时间的搜索,我找到了解决方案,将"template“替换为"ng-template”是其中一个解决方案,但这个问题是因为如果您使用的是与ngx-bootstrap不兼容的对等版本,那么它就是一个错误。以前容易出错的package.json是这样的。这就是我解决问题的方法。
{
....
....
"dependencies": {
"@angular/animations": "5.0.4",
"@angular/cdk": "5.0.0-rc.2",
"@angular/common": "5.0.4",
"@angular/compiler": "5.0.4",
"@angular/core": "5.0.4",
"@angular/forms": "5.0.4",
"@angular/http": "5.0.4",
"@angular/material": "5.1.0",
"@angular/platform-browser": "5.0.4",
"@angular/platform-browser-dynamic": "5.0.4",
"ng2-bootstrap": "^1.2.5",
"ng2-tour": "0.1.6",
....
....
}下面是版本的修复,所以我使用了"ngx-bootstrap": "^2.0.2", "ngx-tour": "0.0.1"。
{
....
....
"dependencies": {
"@angular/animations": "5.0.4",
"@angular/cdk": "5.0.0-rc.2",
"@angular/common": "5.0.4",
"@angular/compiler": "5.0.4",
"@angular/core": "5.0.4",
"@angular/forms": "5.0.4",
"@angular/http": "5.0.4",
"@angular/material": "5.1.0",
"@angular/platform-browser": "5.0.4",
"@angular/platform-browser-dynamic": "5.0.4",
"ngx-bootstrap": "^2.0.2",
"ngx-tour": "0.0.1,
....
....
}并在app.module.ts中更改以导入TourNgBootstrapModule。
`import {TourNgBootstrapModule} from 'ngx-tour-ng-bootstrap';`发布于 2018-02-22 21:46:48
错误说明了一切。标记<template>将被放弃,因此您需要在您的html中将其更改为<ng-template>
发布于 2018-02-23 01:19:29
看起来您使用的是1.9.3版。
ngx-bootstrap 1.9.3只支持angular 2和angular 4。请更新到最新版本(2.0.2),它将与angular 5兼容
https://stackoverflow.com/questions/48928834
复制相似问题