Angular 更改路线材料表时闪烁

Angular 更改路线材料表时闪烁,angular,angular-material,ngrx-store,Angular,Angular Material,Ngrx Store,我使用ngrx@store处理数据,我还使用角材料表显示数据,包括搜索、分页等 在表加载时,我显示一条消息等待一秒钟…,在这条消息之后,我通常使用tablepagesize=“10”获取表中的数据。我从你那里得到这些数据ngrx@store 当我走任何路线并带着表格再次返回此页面时,表格闪烁并显示所有数据(100+项),半秒钟后,它们返回到正常状态,并显示pagesize=“10” 下面是我如何从ngOnInit(){…} this.store.dispatch(new fromStore.Us

我使用
ngrx@store
处理数据,我还使用
角材料表
显示数据,包括搜索、分页等

在表加载时,我显示一条消息等待一秒钟…,在这条消息之后,我通常使用table
pagesize=“10”
获取表中的数据。我从你那里得到这些数据ngrx@store

当我走任何路线并带着表格再次返回此页面时,表格闪烁并显示所有数据(100+项),半秒钟后,它们返回到正常状态,并显示
pagesize=“10”

下面是我如何从
ngOnInit(){…}

this.store.dispatch(new fromStore.UserActions.LoadUsers());
this.users$ = this.store.select(fromStore.UserSelectors.getUsersAll);
this.users$.pipe(takeUntil(this.destroy$)).subscribe(user => { 
  this.dataSource.data = user;
  this.dataSource.sort = this.sort;
  this.dataSource.paginator = this.paginator;
}
在我定义构造函数之前

 @ViewChild(MatPaginator, { static: false }) paginator: MatPaginator;
 @ViewChild(MatSort, { static: false }) sort: MatSort;
这里我显示加载消息

<ng-container matColumnDef="noData">
  <mat-footer-cell *matFooterCellDef colspan="6">
    Wait for a second... data are loading...
  </mat-footer-cell>
</ng-container>
<ng-container matColumnDef="loading">
  <mat-footer-cell *matFooterCellDef colspan="6">
    There is no any data...
  </mat-footer-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
<mat-footer-row *matFooterRowDef="['loading']" [ngClass]="{ hide: dataSource != null }"></mat-footer-row>
<mat-footer-row *matFooterRowDef="['noData']" [ngClass]="{ hide: !(dataSource != null && dataSource.data.length == 0) }"></mat-footer-row>

等一下。。。数据正在加载。。。
没有任何数据。。。

您是否尝试过取消对NGD的订阅?这似乎是个问题。是的,我总是取消takeUntil和alson的预订,很抱歉我不在。做一件事。将订阅放在构造函数中,并在ngOnInit()上加载用户。这应该可以解决问题。如果没有,那么请提供stackblitz链接,这样我就可以看到它了。Thnx,我会在明天回到办公室时尝试。没有工作。。。。我做了同样的“变通方法”,并将其换行到
setTimeout(()=>this.loader=false;this.dataSource.data=this.newVarForAllUsers;)})
。在这种方式下,我显示装载机在闪烁