力触及 ngModel
Force touched on ngModel
我想在单击“提交”时在 angular material 中设置红色要求,为此我需要强制触摸输入。
<div class="formRow">
<mat-form-field class="profile-field" style="width: 40%" appearance="outline">
<input required #personalInfoFirstName
class="profile-input" matInput
placeholder="firstname" name="firstName"
[(ngModel)]="firstName" #tst="ngModel">
</mat-form-field>
</div>
<div>touched = {{tst.touched}}</div>
如何将强制触摸 (tst.touched) 设置为 [(ngModel)]?
抓取#tst
,你可以使用tst.control.markAsTouched()
改变它的状态。
我想在单击“提交”时在 angular material 中设置红色要求,为此我需要强制触摸输入。
<div class="formRow">
<mat-form-field class="profile-field" style="width: 40%" appearance="outline">
<input required #personalInfoFirstName
class="profile-input" matInput
placeholder="firstname" name="firstName"
[(ngModel)]="firstName" #tst="ngModel">
</mat-form-field>
</div>
<div>touched = {{tst.touched}}</div>
如何将强制触摸 (tst.touched) 设置为 [(ngModel)]?
抓取#tst
,你可以使用tst.control.markAsTouched()
改变它的状态。