我有一个角形(不是反应性的),它有一些必填字段,如果在提交表单期间为空,则会用红色突出显示。现在,如果我提交表单,然后清空必填字段,则这些字段仍会突出显示(即使不再提交表单)。有没有办法在再次提交表单之前不显示此验证?
<form name="form" (ngSubmit)="f.form.valid && moveAsset()" #f="ngForm" novalidate>
<button type="submit" id="MoveAsset" name="MoveAsset" tabindex="214"
class="btn btn-primary pull-right" data-dismiss="modal"
[disabled]="assetMoveFieldAccessData['Move']">
{{fields['Move']}}
</button>
<div class="form-group required">
<label class="col-form-label control-label col-sm-4 for="site">
{{fields['Site']}}
</label>
<ng-select ngSelectSetTabindex [items]="siteList" name="siteid" id="siteid" tabindex="204"
(change)="siteChange()" bindLabel="siteName" bindValue="siteId" [(ngModel)]="site"
#siteid="ngModel" required placeholder="{{fields['Select Site']}}"
[ngClass]="{ 'invalid-errors-br': (f.submitted && (site == 0|| site == null || site ==
undefined))}" >
</ng-select>
</div>
</form>
组件:
myform: FormGroup;
@ViewChild('f', {static: true}) myForm;
public moveAsset(){
this.myForm.reset();
}