【问题标题】:Angular 2: ngIf template parsing errorAngular 2:ngIf 模板解析错误
【发布时间】:2017-10-06 22:02:46
【问题描述】:

我有一个动态模板,但我收到一条错误消息:

Template parse errors: Unexpected closing tag "button". It may happen when the tag has already been closed by another tag.

这是我的模板:

<ion-col>
    <button *ngIf=!editMode" class="warning-gradient" (click)="toggleEdit()"><i class="fa fa-edit"></i>Update</button>
    <button *ngIf="editMode" class="warning-success" (click)="submitForm()"><i class="fa fa-check"></i>Update</button>
</ion-col>

...我应该做一些不同的事情吗?

【问题讨论】:

  • *ngIf="!editMode" 你错过了第一个按钮上的 " 开头
  • @jmw5598 为什么不将其添加为答案?似乎是OP的解决方案
  • 天啊...我盯着那个看了这么久

标签: ionic2 angular2-template angular-ng-if


【解决方案1】:

您在第一个 &lt;button&gt; 上缺少 *ngIf 属性的开头 "

<ion-col>
    <button *ngIf="!editMode" class="warning-gradient" (click)="toggleEdit()"><i class="fa fa-edit"></i>Update</button>
    <button *ngIf="editMode" class="warning-success" (click)="submitForm()"><i class="fa fa-check"></i>Update</button>
</ion-col>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-10
    • 2016-09-24
    • 2017-06-17
    • 2017-09-29
    • 2017-10-24
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多