【问题标题】:Angular-Material:- Template error for mat-radio-buttonAngular-Material:- mat-radio-button 的模板错误
【发布时间】: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 语法错误。

标签: angular angular-material


【解决方案1】:

只需检查相应的 (your-module-name).module.ts 文件,是否已导入“MatRadioModule”。

【讨论】:

    猜你喜欢
    • 2019-02-06
    • 2019-05-22
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2018-10-01
    • 2020-12-01
    • 1970-01-01
    相关资源
    最近更新 更多