I have a simple Submit button and have Mat-Spinner to show the progress. After the call either its Success or Error, my isLoading is not setting to False, because of which my spinner is showing always
Here is the below code
<code>if (this.basicInfo.valid) {
this.isLoading = true;
let saveData = this.basicInfo.value
this.apiSvc.create(saveData).subscribe({
next: (data) => {
this.isLoading = false;
},
error: (error: HttpErrorResponse) => {
this.isLoading = false;
},
});
}
<button
mat-flat-button
[disabled]="!basicInfo.valid"
class="custom-width-button"
>
<mat-spinner
[diameter]="24"
class="white-spinner"
*ngIf="isLoading"
></mat-spinner>
</button>
</code>
<code>if (this.basicInfo.valid) {
this.isLoading = true;
let saveData = this.basicInfo.value
this.apiSvc.create(saveData).subscribe({
next: (data) => {
this.isLoading = false;
},
error: (error: HttpErrorResponse) => {
this.isLoading = false;
},
});
}
<button
mat-flat-button
[disabled]="!basicInfo.valid"
class="custom-width-button"
>
<mat-spinner
[diameter]="24"
class="white-spinner"
*ngIf="isLoading"
></mat-spinner>
</button>
</code>
if (this.basicInfo.valid) {
this.isLoading = true;
let saveData = this.basicInfo.value
this.apiSvc.create(saveData).subscribe({
next: (data) => {
this.isLoading = false;
},
error: (error: HttpErrorResponse) => {
this.isLoading = false;
},
});
}
<button
mat-flat-button
[disabled]="!basicInfo.valid"
class="custom-width-button"
>
<mat-spinner
[diameter]="24"
class="white-spinner"
*ngIf="isLoading"
></mat-spinner>
</button>