If I click fast on my submit-button the form is submitted two or more times. My thought was to prevent this with the disabled attribute, but I need variable disableButon>
I have a slight different way (maybe more simple) of dealing with this - same principles apply though.
Essentially what I will do is:
Here is my html template code:
And here is my class:
export class UpdateForm {
disableButton: boolean;
constructor() { this.disableButton = false; }
handleSubmit(formData: any, isValid: boolean) {
if (isValid) {
this.disableButton = true; // the button will then be disabled
onHandleUpdate(formData);
}
}
onHandleUpdate(formData) {
this.disableButton = false; // the button will renable
}
}