意外的结束标记“div”错误 angular2 HTML

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41489294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:13:11  来源:igfitidea点击:

Unexpected closing tag "div" error angular2 HTML

htmlangular

提问by Cookies

I'm getting some errors in the console and not sure what is the issue is in the HTML. Any help would be appreciated.

我在控制台中遇到一些错误,但不确定HTML. 任何帮助,将不胜感激。

error_handler.js:51 EXCEPTION: Uncaught (in promise): Error: Template parse errors: Unexpected closing tag "div" (" Click here to Signup [ERROR ->] "): ResetPassword@22:1 Error: Template parse errors: Unexpected closing tag "div" (" Click here to Signup [ERROR ->] "): ResetPassword@22:1

error_handler.js:51 例外:未捕获(承诺):错误:模板解析错误:意外的结束标记“div”(“单击此处注册 [错误 ->]”):ResetPassword@22:1 错误:模板解析错误:意外的结束标记“div”(“单击此处注册 [ERROR ->]”):ResetPassword@22:1

<section class="reset-password">
<div class="container container-responsive inner-top-xs">
    <form [formGroup]="resetPasswordForm" (ngSubmit)="resetPassword(resetPasswordForm.value, resetPasswordForm.valid)">
        <h4>Please enter your e-mail address and a temporary password will be sent to you.</h4>
        <div class="form-group">
            <label class="control-label" for="email">Email</label>
            <input type="text" formControlName="email" required class="form-control" id="email" placeholder="Email">
            <validation-message [control]="resetPasswordForm.controls.email"></validation-message>
        </div>
        <button type="submit" class="btn btn-flat__blue outer-top-xs" [disabled]="!resetPasswordForm.valid">RESET PASSWORD</button>
    </form>
    <div class="alert alert-dismissible alert-danger outer-top-xs" *ngIf="errorMessage && !successMessage"">
      <button type="button" class="close" data-dismiss="alert">&times;</button>
      {{errorMessage}}
    </div>
    <div class="alert alert-dismissible alert-success outer-top-xs" *ngIf="successMessage">
      <button type="button" class="close" data-dismiss="alert">&times;</button>
      {{successMessage}}
    </div>
    <div class="outer-top-xs">
        <a [routerLink]="['/getstarted']">Click here to Signup</a>
    </div>
</div>
</section>

回答by Poul Kruijt

You've got one double quote too many at *ngIf="errorMessage && !successMessage"":

您在以下位置有太多的双引号*ngIf="errorMessage && !successMessage""

<div class="alert alert-dismissible alert-danger outer-top-xs" *ngIf="errorMessage && !successMessage"> 
<!--at the end of this line-->

回答by Iman Bahrampour

This error occurred when you open an element and don't close its. this error shows up in this example:

当您打开一个元素但不关闭它时会发生此错误。此错误显示在此示例中:

<ion-list *ngSwitchCase="'facilities'">
 <ion-item *ngFor="let facility of facilities">
  <ion-icon name="facility.Icon" item-start></ion-icon>
  {{facility.Name}}
  <ion-icon color="red" name="rose" item-end></ion-icon>
 </ion-item> 
<ion-list>

As you see I don't close <ion-list>element (should be </ion-list>)

如您所见,我没有关闭<ion-list>元素(应该是</ion-list>

Be careful:

当心:

If you use any element properties with its values as the parser can't handle them, the element will be opened and this error occurs( "" at above example).

如果您使用任何元素属性及其值,因为解析器无法处理它们,则该元素将被打开并发生此错误(“”在上面的示例中)。