【发布时间】:2019-11-09 18:02:29
【问题描述】:
我正在使用 Angular 材料并遇到一个错误,尽管它在 stackblitz 上运行良好,但在我的代码上却不行。以下是我面临的错误 我也导入了 MatRadioModule。
Uncaught Error: Template parse errors:
Unexpected character "EOF" ("</mat-radio-button>
<mat-radio-button value="2">Option 2</mat-radio-button>
</mat-radio-group[ERROR ->]"): ng:///AppModule/RadioButtonsComponent.html@18:19
at syntaxError (compiler.js:485)
at DirectiveNormalizer._preparseLoadedTemplate (compiler.js:3220)
at eval (compiler.js:3200)
at Object.then (compiler.js:474)
at DirectiveNormalizer._preParseTemplate (compiler.js:3200)
at DirectiveNormalizer.normalizeTemplate (compiler.js:3178)
at CompileMetadataResolver.loadDirectiveMetadata (compiler.js:14908)
at eval (compiler.js:34412)
at Array.forEach (<anonymous>)
at eval (compiler.js:34411)
下面是我的 HTML 代码
<mat-radio-group>
<mat-radio-button value="1">Option 1</mat-radio-button>
<mat-radio-button value="2">Option 2</mat-radio-button>
</mat-radio-group>
【问题讨论】:
-
你能把整个代码贴出来吗?
-
我只用过html你需要package.json吗?
-
整个html文件
-
这就是我所拥有的。它是一个新的 html 页面
-
此错误可能源于其他组件/html 文件,这些文件使用 mat 单选按钮嵌入了您的组件。您必须检查 index.html 的所有组件是否存在 html 语法错误。