Reputation: 11
I want to use a material table and a material spinner.
I dont know how to show table only when spinner is loading and vice versa.
Upvotes: 0
Views: 1594
Reputation: 4910
Do something like this:
loading: boolean;
getTable() {
loading = true;
// Once table is done:
loading = false;
}
<div *ngIf="loading">
<mat-spinner></mat-spinner>
</div>
<div *ngIf="!loading">
table here...
</div>
Or you could also set loading to true so that the spinner will show on page load. Though if i were you, I'd build a component/service that automatically does this anytime you are fetching data. Unless of course this is the only place you fetch data
Upvotes: 1