[英]Mat spinner with condition keeps on rotating even after change in condition
I'm using a mat-spinner to rotate till I get the data from the service to display in a table. 我正在使用mat-spinner旋转,直到我从服务中获取数据以显示在表格中。 Once the data is received, I change the condition and mat-spinner should stop rotating.
一旦收到数据,我就改变了条件,mat-spinner应该停止旋转。 However, it takes a lot of time after the data is received from the service to stop rotating.
但是,从服务接收数据以停止旋转需要花费很多时间。
This is my existing code 这是我现有的代码
In table.html 在table.html中
<mat-card *ngIf="isLoading2 === true; else elseBlock" class = "snapshot-spinner">
<mat-progress-spinner color="primary" mode="indeterminate">
</mat-progress-spinner>
</mat-card>
<ng-template #elseBlock class="container" style="padding-bottom: 10px; padding-top: 20px">
<table class='reports'>
<tr>
<th class="reports-data">Data1 : {{ SnapshotData.Data1 }}</th>
<th class="reports-data">Data2 : {{ SnapshotData.Data2 }} </th>
<th class="reports-data">Data3 : {{ SnapshotData.Data3 }}</th>
<th class="reports-data">Data4 : {{ SnapshotData.Data4 }}</th>
</tr>
</table>
</ng-template>
In table.ts 在table.ts
this.messageService.getSnapshotDetails().subscribe(
response => {
this.SnapshotData = response;
console.log(this.SnapshotData);
this.isLoading2 = false;
console.log(this.isLoading2);
},
errorResponse => { console.log(errorResponse), this.isLoading2 = false },
);
Why does the mat-spinner take so much time to stop even after the value of isLoading2 changes to false? 为什么即使在isLoading2的值变为false之后,mat-spinner也会花费很多时间来停止? How do I solve this?
我该如何解决这个问题?
I don't think you need to add the ===true. 我认为你不需要添加=== true。 Did you try to write it just like this?
你试着像这样写吗?
<mat-card *ngIf="isLoading2 === true; else elseBlock" class = "snapshot-spinner">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.