In template-driven form, we can check that with the submitted
property from NgForm
. But how to achieve that in Model-driven form?
答案 0 :(得分:14)
我发现您可以将ngForm
与formGroup
一起使用:
<form [formGroup]='form' #ngForm="ngForm" (ngSubmit)='validation(ngForm)'
[ngClass]="{ 'form-unsubmitted': !ngForm.submitted}">
答案 1 :(得分:2)
create one variable IsSubmitted = false
into component.
once submit a button you can set it true into onSubmit()
function.
for example :
onSubmit(): void{
this.isSubmited = true;
// code....
}
set it again false into after response