angular - Angular:模板解析错误:解析器错误:意外标记 = 在列
问题描述
我正在编写一个使用 Angular CLI 构建的 Angular 应用程序。新模板解析器报告以下意外令牌错误。
Angular抛出错误,如
**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 中的错误。
解决方案
删除表单 Onsubmit 的最后一个参数的逗号。
onSubmit(firstName.value,
lastName.value,
name.value,
email.value)
推荐阅读
- php - PHPUnit 测试常量
- java - TestNG框架中的主要方法在哪里
- java - EntityManager Hibernate 5 没有持久性提供程序
- python - 通过 Web 服务公开 R 和 Python 脚本
- java - 将现有缓存作为映射转换为 Spring @Cacheable
- javascript - Chart.js - 如何调用未命名图表的更新函数?
- java - 如何禁用与 x11 窗口服务器的连接
- sql-server - 我们无法使用 POWER BI 提供的凭据进行身份验证
- python - 从 CLI 安装 W10 商店应用程序
- cpu - 在基于 debian 的 linux 中更改最大处理器状态值