I am facing an issue retrieving data from my backend server.
file.html
<div *ngIf="shouldDisplay">
<p> information to display </p>
<button mat-flat-button type="button" (click)="update()">
update
</button>
</div>
file.ts
shouldDisplay: boolean;
ngOnInit() {
this.initialize();
}
initialize() {
this.fileService.check().subscribe(data => {
this.shouldDisplay = data;
});
}
update(){
this.initialize();
if(this.shouldDisplay){
this.fileService.update();
} else {
this.notificationService.error('errorMessage');
}
}
I need the 'shouldDisplay' variable to be set as true in the 'check' method response. Also, I want to utilize the 'shouldDisplay' variable in the 'update' method.