如何仅在 Angular Dart 中提交时验证表单?
How to validate Form only on submit in Angular Dart?
我正在使用 Angular 组件库,其中包括 material-input。有没有办法在更改或清空 material-input 时禁用 input auto validate?这意味着我只想在 提交 时 验证 表单。
此外,尽管 material-按钮 的类型为提交,但提交时不会触发 onSignInPressed() 函数。
<div class="container">
<form (ngSubmit)="onSignInPressed()" #signInForm="ngForm">
<div>
<material-input
floatingLabel type="email"
label="E-mail"
[(ngModel)]="email"
ngControl="email"
required></material-input>
</div>
<div>
<material-input
floatingLabel type="password"
label="Password"
[(ngModel)]="password"
ngControl="pass"
required></material-input>
</div>
<div class="w-100">
<material-button class="mx-0 btn-primary w-100 margin-zero" type="submit"
[disabled]="!signInForm.form.valid">
Sign In
</material-button>
</div>
</form>
</div>
我正在使用 Angular 组件库,其中包括 material-input。有没有办法在更改或清空 material-input 时禁用 input auto validate?这意味着我只想在 提交 时 验证 表单。
此外,尽管 material-按钮 的类型为提交,但提交时不会触发 onSignInPressed() 函数。
<div class="container">
<form (ngSubmit)="onSignInPressed()" #signInForm="ngForm">
<div>
<material-input
floatingLabel type="email"
label="E-mail"
[(ngModel)]="email"
ngControl="email"
required></material-input>
</div>
<div>
<material-input
floatingLabel type="password"
label="Password"
[(ngModel)]="password"
ngControl="pass"
required></material-input>
</div>
<div class="w-100">
<material-button class="mx-0 btn-primary w-100 margin-zero" type="submit"
[disabled]="!signInForm.form.valid">
Sign In
</material-button>
</div>
</form>
</div>