import {Component, OnInit, ViewChild} from '@angular/core'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import {TableListDataSource} from './table-list-datasource'; import {Table} from '../../core/table'; import {ActivatedRoute} from '@angular/router'; @Component({ selector: 'app-table-list', templateUrl: './table-list.component.html', styleUrls: ['./table-list.component.css'] }) export class TableListComponent implements OnInit { @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatSort, { static: true }) sort: MatSort; dataSource: TableListDataSource; list: Table[]; /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */ displayedColumns = ['name', 'isActive']; constructor(private route: ActivatedRoute) { } ngOnInit() { this.route.data .subscribe((data: { list: Table[] }) => { this.list = data.list; }); this.dataSource = new TableListDataSource(this.paginator, this.sort, this.list); } }