import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Customer } from '../../core/customer'; import { CustomerListDatasource } from './customer-list-datasource'; @Component({ selector: 'app-customer-list', templateUrl: './customer-list.component.html', styleUrls: ['./customer-list.component.css'], }) export class CustomerListComponent implements OnInit { dataSource: CustomerListDatasource = new CustomerListDatasource([]); list: Customer[] = []; /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */ displayedColumns = ['name', 'phone', 'address']; constructor(private route: ActivatedRoute) {} ngOnInit() { this.route.data.subscribe((value) => { const data = value as { list: Customer[] }; this.list = data.list; }); this.dataSource = new CustomerListDatasource(this.list); } }