模板解析angular2模板中的错误

时间:2021-07-23 11:43:15

I have the following template for my angular 2 component, but it is throwing a template parse error.

我的角度2组件有以下模板,但它抛出了模板解析错误。

<div *ngIf="chapter == 1">
        <p><h4><br><b>Exercise</b>: Get the Groceries starting point<br></h4></p>
</div>

this is the error message - what's wrong with my </p> tag?

这是错误信息 - 我的 标签出了什么问题?

zone.js:461 Unhandled Promise rejection: Template parse errors: Unexpected closing tag "p" ("gIf="chapter == 1">

zone.js:461未处理的Promise拒绝:模板解析错误:意外的结束标记“p”(“gIf =”chapter == 1“>

   <p><h4><br><b>Exercise</b>: Get the Groceries starting point<br></h4>

[ERROR ->]

[错误 - >]

</div>

"): chapterComponent@45:77 ; Zone: ; Task: Promise.then ; Value: BaseException {message: "Template parse errors:↵Unexpected closing tag "p" …ROR ->]

“):chapterComponent @ 45:77;区域:;任务:Promise.then;值:BaseException {message:”模板解析错误:↵意外结束标记“p”... ROR - >]

↵ ↵ ↵"): chapterComponent@45:77", stack: "Error: Template parse errors:↵Unexpected closing t…st:3000/node_modules/zone.js/dist/zone.js:426:22)"}consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 zone.js:463 Error: Uncaught (in promise): Template parse errors:(…)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426

1 个解决方案

#1


1  

The problem is that header h4 in your paragraph! Its no valid HTML code.

问题是你的段落中的标题h4!它没有有效的HTML代码。

https://*.com/a/15656988/3631348

https://*.com/a/15656988/3631348

Do it without that p ?! Or move the header right before your paragraph..

没有那个p吗?或者在你的段落之前移动标题..

<h4><br><b>Exercise</b>: Get the Groceries starting point<br></h4>

#1


1  

The problem is that header h4 in your paragraph! Its no valid HTML code.

问题是你的段落中的标题h4!它没有有效的HTML代码。

https://*.com/a/15656988/3631348

https://*.com/a/15656988/3631348

Do it without that p ?! Or move the header right before your paragraph..

没有那个p吗?或者在你的段落之前移动标题..

<h4><br><b>Exercise</b>: Get the Groceries starting point<br></h4>