środa, 21 lutego 2018

How to solve TypeError: date.split is not a function in JHipster

If you get:
ERROR TypeError: date.split is not a function
    at JhiDateUtils.toDate

probably you have to add date transform in PopupService.

Date format should be like: 2018-02-12T13:05:54

Change:

1
2
3
4
5
            if (id) {
                this.barCashupService.find(id).subscribe((barCashup) => {
                    this.ngbModalRef = this.barCashupModalRef(component, barCashup);
                    resolve(this.ngbModalRef);
                });

to:

1
2
3
4
5
6
7
8
9
            if (id) {
                this.barCashupService.find(id).subscribe((barCashup) => {
                    barCashup.barmanLoginTime = this.datePipe
                        .transform(barCashup.barmanLoginTime, 'yyyy-MM-ddTHH:mm:ss');
                    barCashup.cashupTime = this.datePipe
                        .transform(barCashup.cashupTime, 'yyyy-MM-ddTHH:mm:ss');
                    this.ngbModalRef = this.barCashupModalRef(component, barCashup);
                    resolve(this.ngbModalRef);
                });


Or if you call entity from function, change:


1
2
3
4
5
  loadLastCashup() {
    this.newDayService.query().subscribe((cashup) => {
      this.lastCashup = cashup;
    });
  }

to:

1
2
3
4
5
6
7
8
9
  loadLastCashup() {
    this.newDayService.query().subscribe((cashup) => {
      this.lastCashup = cashup;
                    this.lastCashup.barmanLoginTime = this.datePipe
                        .transform(this.lastCashup.barmanLoginTime, 'yyyy-MM-ddTHH:mm:ss');
                    this.lastCashup.cashupTime = this.datePipe
                        .transform(this.lastCashup.cashupTime, 'yyyy-MM-ddTHH:mm:ss');
    });
  }



Brak komentarzy:

Prześlij komentarz