【问题标题】:Angular html error in Mat select and mat optionMat选择和mat选项中的Angular html错误
【发布时间】:2019-12-11 11:28:34
【问题描述】:

我正在尝试运行此代码

<mat-header-cell *matHeaderCellDef mat-sort-header class="header-primary-text"> Response </mat- header-cell>
<mat-cell *matCellDef="let element">
  <!-- Code for new questions and dropdown - Ramki -->
  <!-- mat-form-field style="width: 48%" -->
  <div *ngIf="element.name == 'Select the complexity of Application'">
    <mat-select [(ngModel)]="element.QuestionCode" placeholder="Select the complexity"
      <mat-option *ngFor="let qc of element.QuestionCode" value="{{qc}}">
        {{qc}} </mat-option>
    </mat-select>
  </div>

我收到如下错误:

意外的结束标记“mat-option”。标签有时可能会发生 已经被另一个标签关闭。有关更多信息,请参阅 https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags

("-option *ngFor="let qc of element.QuestionCode" value="{{qc}}">
{{qc}} [ERROR ->]</mat-option>
</mat-select>
</div>

我哪里出错了?

我是 Angular 的新手。感谢任何帮助

【问题讨论】:

  • 当您的 HTML 未正确关闭时会发生这种情况。
  • 现在检查更正的代码。关闭标签未正确关闭。
  • 标签未正确关闭:末尾缺少 >(在占位符属性之后)。
  • HI Aviboy:我在哪里可以找到更正的代码?

标签: angular


【解决方案1】:

我遇到了类似的问题,我以这种方式解决了。它可能会帮助许多像我一样面临同样问题的人。

<div *ngIf="element.name == 'Select the complexity of Application'">
    <mat-select [(ngModel)]='"element.QuestionCode"' placeholder="Select the complexity"
      <mat-option *ngFor="let qc of element.QuestionCode" [value]='qc'>
        {{qc}} </mat-option>
    </mat-select>
  </div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-22
    • 2020-07-11
    • 2019-02-18
    • 1970-01-01
    相关资源
    最近更新 更多