import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from "@angular/core";
import {HttpClient} from "@angular/common/http";

@Component({
  moduleId: module.id,
  selector: 'data-date',
  templateUrl: '../../../../../src/resources/template/app/component/data-date.html',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class DataDateComponent {

  public dataDate: string;

  constructor(private httpClient: HttpClient, private cd: ChangeDetectorRef) {
    this.getLastRecordDate();
  }

  private getLastRecordDate(): void {
    this.httpClient.get("data-date").toPromise()
        .then((dataDate: string) => {
          this.dataDate = dataDate;
          this.cd.markForCheck();
        });
  }
}