import { Component, OnInit } from '@angular/core'; import { MatTableDataSource } from '@angular/material/table'; import { OverheadAdvanceService } from '../data-object-service'; import { OverheadAdvance } from '../data-objects'; import { MessageService } from '../message.service'; @Component({ selector: 'app-overhead-advance-list', templateUrl: './overhead-advance-list.component.html', styleUrls: ['./overhead-advance-list.component.css'] }) export class OverheadAdvanceListComponent implements OnInit { overheadAdvances: OverheadAdvance[] dataSource: MatTableDataSource displayedColumns: string[] = [ "description", "amount", "startdate", "enddate" ] constructor( private overheadAdvanceService: OverheadAdvanceService, private messageService: MessageService ) { } async getOverheadAdvances(): Promise { try { this.messageService.add("Trying to load overheadAdvances") this.overheadAdvances = await this.overheadAdvanceService.getOverheadAdvances() this.messageService.add("OverheadAdvances loaded") this.dataSource = new MatTableDataSource(this.overheadAdvances) } catch (err) { this.messageService.add(`Error in getOverheadAdvances: ${ JSON.stringify(err, undefined, 4) }`) } } ngOnInit(): void { this.messageService.add("OverheadAdvanceListComponent.ngOnInit") this.getOverheadAdvances() } }