角度:模板解析错误:解析器错误:意外的标记=在列上

问题描述 投票:0回答:1

我正在编写一个使用Angular CLI构建的Angular应用。新的模板解析器报告以下意外的令牌错误。

[Angular throws error like

**ERROR in Template parse errors**:
Parser Error: Unexpected token ) at column 158 in [
            onSubmit(
                firstName.value,
                lastName.value,
                name.value,
                email.value,
            )

处理时

<div *ngIf="user$ | async as user; else loginArea">
    <p *ngIf="user.emailVerified">xxxxxx</p>
    <p *ngIf="!user.emailVerified">yyyyy</p>
    <button (click)="logout()">logout</button>
</div>

<ng-template #loginArea>
    <mat-card class="sign-up-card">
        <mat-card-header>
            <mat-card-title class="sign-up-title">zzz</mat-card-title>
        </mat-card-header>

        <mat-card-content>
            <form #form="ngForm" (submit)="
            onSubmit(
                firstName.value,
                lastName.value,
                name.value,
                email.value,
            )
          ">
                <mat-form-field fxFill appearance="outline">
                    <mat-label>first name</mat-label>
                    <input #firstName matInput required ngModel name="firstName" />
                </mat-form-field>
                <mat-form-field fxFill appearance="outline">
                    <mat-label>last name</mat-label>
                    <input #lastName matInput required ngModel name="lastName" />
                </mat-form-field>
                <mat-form-field fxFill appearance="outline">
                    <mat-label>email</mat-label>
                    <input #email matInput required type="email" pattern=".+@.+\..+" ngModel name="email" />
                </mat-form-field>
                <mat-form-field fxFill appearance="outline">
                    <mat-label>password</mat-label>
                    <input #password matInput required type="password" ngModel name="password" />
                </mat-form-field>
                <div fxLayout="row">
                    <div>
                        <mat-checkbox fxFill required ngModel name="agree">
                            aaaa
                        </mat-checkbox>
                    </div>
                    <span fxFlex="1 1 auto"></span>
                    <a routerLink="/terms">
                        bbbb
                    </a>
                </div>
                <button mat-raised-button fxFill [color]="'accent'" [disabled]="form.invalid">
                    sign up
                </button>
            </form>
            <button type="button" (click)="resetPassword()" [disabled]="form.get('email').invalid">
                reset password
            </button>
        </mat-card-content>
    </mat-card>
</ng-template>

我不知道语法有什么变化,所以我假设这是TemplateGenerator中的错误。

angular parse-error
1个回答
0
投票

在形式为Onsubmit的最后一个参数处删除逗号。

onSubmit(firstName.value,
         lastName.value,
         name.value,
         email.value)
© www.soinside.com 2019 - 2024. All rights reserved.