I've been working on a way to hide the table and the 'changeState' button when there's no data present. Currently, I have set it up so that a message saying 'No entries in the list!' pops up briefly before disappearing, bringing back the table and button. Is there a better way to achieve this?
Below is the HTML snippet:
<app-header [isHidden]="isHiddenProgressBar"></app-header>
<div class="change">
<button (click)="changeState()" *ngIf="showButton" color="primary" mat-raised-button>Change state</button>
</div>
<div class="list">
<app-list *ngIf="visible" [changeObjects]="data"></app-list>
<ng-container *ngIf="!data">
No entries in the list!
</ng-container>
</div>
And here is the corresponding TypeScript code section:
this.data = this.objects;
this.visible = this.objects != null && this.objects.length > 0;
this.showButton = true;
//additional condition for handling empty data
if(!this.objects) {
this.showButton = false;
this.visible = false;
}
Your input would be greatly appreciated!