我正在使用角度材料创建登录表单,但是提交按钮不起作用,并且我在控制台中没有收到任何错误。起初我尝试通过它发布一个http请求但它不起作用,所以我只是使用一个简单的日志来测试它仍然不起作用。
登录.html:
<mat-card>
<mat-card-content>
<form class="my-form" #loginForm=ngForm (ngSubmit)="Submit()">
<mat-form-field class="full-width">
<mat-label>Email</mat-label>
<input matInput class="form-control" [formControl]="emailControl" placeholder="Enter Your Nickname"
type="email">
<mat-error *ngIf="emailControl.hasError('email')">
Please enter a valid email address
</mat-error>
<mat-error *ngIf="emailControl.hasError('required')">
Email is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field class="full-width">
<mat-label>Password</mat-label>
<input [formControl]="passwordControl" matInput name="password" type="password" class="form-control"
placeholder="Enter Your Password">
<mat-error *ngIf="passwordControl.hasError('required')">
Password is <strong>required</strong>
</mat-error>
<mat-error *ngIf="passwordControl.hasError('minLength')">
Password should be more then 7 characters
</mat-error>
</mat-form-field>
</form>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button type="submit" color="primary">LOGIN</button>
</mat-card-actions>
</mat-card>
Run Code Online (Sandbox Code Playgroud)
登录.组件.ts:
import { CustomValidators } from '../../custom-validators'; …Run Code Online (Sandbox Code Playgroud)