I have a problem where my view will not change when I update my variable in my observable subscription. I am trying to show a loading spinner while I wait for a response from my backend and then display the response, but the spinner won't hide. My subscription looks like this:
this.isRequesting = "true";
this.questionService.onSubmit(form, this.questions).subscribe( (value) => {
this._ngZone.run( () => {
this.fileLocation = JSON.stringify(value);
console.log(this.fileLocation);
this.isRequesting = "false";
console.log(this.isRequesting);
});
});
And my html for this component looks like this:
<spinner *ngIf="isRequesting=='true'"></spinner>
I can see that isRequesting changes to "false" in my console after I get a response back from the backend (Springboot), but the view still does not change. The spinner was from SpinKit and I modified this tutorial for my spinner to work.
I have tried:
- The way in the tutorial (with stopRefreshing() in the error and complete parameters of the observable)
- ngZone to force my view to update.
Does anyone have any ideas on how to get my view to update or any way to get my spinner to hide after I get a response from my backend?