我使用Angular 6,Firebase和Angular Material。
我在firebase中存储了30,000个json对象,我想将它们加载到mat-table中。只有我低于我希望的方式。我等了30秒才能点击我的应用程序,有时铬错误...
然而,我在分页后加载了我的数据。
有人能告诉我这是否正常或是否有策略来克服这个问题?谢谢。
也许我可以用角度7和无限滚动来做到这一点?你有一个例子吗?
export class TableComponent implements OnInit {
showSpinner = true;
Data = {nom: '', finessgeo: '', cat1: '', commune: '', CP: '', departement: '', tel: ''}
displayedColumns = ['nom', 'finessgeo', 'cat1', 'commune', 'CP', 'departement', 'tel'];
dataSource = new MatTableDataSource();
applyFilter(filterValue: string) {
filterValue = filterValue.trim();
filterValue = filterValue.toLowerCase();
this.dataSource.filter = filterValue;
}
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
return this.geoService.getGeos().subscribe(res => {
this.dataSource.data =
res;
this.showSpinner = false;
});
}
constructor(public authService: AuthService, private geoService:
GeoService, private router: Router, private database: AngularFireDatabase) {
}
ngOnInit() {}
}
我有一些建议。
第一:不要将所有30k行加载到客户端。尝试使用服务器端分页。这应该解决所有问题。此外,您必须在api上实现所有过滤和排序功能。使用客户端只显示该数据。
如果这不是一个选项: