Files
brewman/overlord/src/app/cost-centre/cost-centre-list/cost-centre-list.component.ts
T
2020-11-23 16:42:54 +05:30

34 lines
1.2 KiB
TypeScript

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