Reset pagination and sorting on secondary page navigation.
This commit is contained in:
		
							parent
							
								
									28fc0048f7
								
							
						
					
					
						commit
						2515ce1d96
					
				@ -1,4 +1,10 @@
 | 
			
		||||
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import {
 | 
			
		||||
  AfterViewInit,
 | 
			
		||||
  ChangeDetectionStrategy,
 | 
			
		||||
  Component,
 | 
			
		||||
  OnInit,
 | 
			
		||||
  ViewChild,
 | 
			
		||||
} from '@angular/core';
 | 
			
		||||
import { MatTableDataSource } from '@angular/material/table';
 | 
			
		||||
import { MatPaginator } from '@angular/material/paginator';
 | 
			
		||||
import { MatSort } from '@angular/material/sort';
 | 
			
		||||
@ -16,7 +22,7 @@ import { AccountDetails } from '@app/_models';
 | 
			
		||||
  styleUrls: ['./accounts.component.scss'],
 | 
			
		||||
  changeDetection: ChangeDetectionStrategy.OnPush,
 | 
			
		||||
})
 | 
			
		||||
export class AccountsComponent implements OnInit {
 | 
			
		||||
export class AccountsComponent implements OnInit, AfterViewInit {
 | 
			
		||||
  dataSource: MatTableDataSource<any>;
 | 
			
		||||
  accounts: Array<AccountDetails> = [];
 | 
			
		||||
  displayedColumns: Array<string> = ['name', 'phone', 'created', 'balance', 'location'];
 | 
			
		||||
@ -53,6 +59,11 @@ export class AccountsComponent implements OnInit {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngAfterViewInit(): void {
 | 
			
		||||
    this.dataSource.paginator = this.paginator;
 | 
			
		||||
    this.dataSource.sort = this.sort;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  doFilter(value: string): void {
 | 
			
		||||
    this.dataSource.filter = value.trim().toLocaleLowerCase();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user