运行Angular应用时出错:仅ng-template元素支持“ let-”

时间:2018-08-13 11:49:32

标签: javascript angular webpack

我将所有软件包更新为Angular 5,但是当我尝试获取localhost:4200时 并在控制台中出现错误:

    Uncaught Error: Template parse errors:
"let-" is only supported on ng-template elements. ("<template #innerView></template>
<template #template [ERROR ->]let-ctx>
    <template [swapCmp]="ctx.component" [swapCmpBindings]="ctx.bindings" [swapCmpProjectable"): ng:///ModalModule/ModalOverlay.html@1:20
    at syntaxError (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:684)
    at TemplateParser.parse (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:24530)
    at JitCompiler._parseTemplate (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33917)
    at JitCompiler._compileTemplate (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33892)
    at eval (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33794)
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33794)
    at eval (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33664)
    at Object.then (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:673)
    at JitCompiler._compileModuleAndComponents (webpack-internal:///./node_modules/@angular/compiler/esm5/compiler.js:33663)

webpack: Compiled successfully在控制台中。

可能是什么问题?

它看起来像Angular的旧版本

3 个答案:

答案 0 :(得分:1)

该错误清楚地说明了"let-" is only supported on ng-template elements.,因此,如果您在其他任何元素中使用let而不是ng-template,那么您将得到此错误。并且您在template中使用let,然后将template的{​​{1}}元素更改为ng-template

答案 1 :(得分:0)

ng-template是Angular4。

尝试用template代替ng-template

答案 2 :(得分:0)

对我来说,帮助是卸载angular2 -modal并安装ngx-modialog,然后更改项目中的软件包。