У меня есть приложение Angular 8. И я использую Datepicker материала.
Но если я укажу дату звонка, вызов get api:
searchFor(filterRegistration: FilterByRegistrationDTO) {
// tslint:disable-next-line: max-line-length
console.log(
this.participantService.filterParticipantsByRegistration(1, "Invited", this.startDate.toString()).subscribe(result => {
console.log(this.startDate.toString());
console.log(result);
})
);
И шаблон будет выглядеть так:
<div>
<mat-form-field class="search-field-input">
<input matInput [matDatepicker]="picker1" placeholder="start datum" [(ngModel)]="startDate" />
<mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker>
</mat-form-field>
</div>
Так на стороне серверадата будет показана как: jjjj-MM-dd.
Но на стороне клиента дата должна быть показана как: dd-MM-jjjj.
Но так, если я позвонюAPI вызов:
console.log(
this.participantService.filterParticipantsByRegistration(1, "Invited", this.startDate.toString()).subscribe(result => {
console.log(this.startDate.toString());
console.log(result);
})
);
Тогда я получу эту ошибку:
core.js:12584 ERROR
HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: "Bad Request", url: "https://dev-engine.mijnhep.nl/api/medical/organisa…GMT%2B0200%20(Central%20European%20Summer%20Time)", ok: false, …}
error:
Start: ["The value 'Mon Oct 07 2019 12:58:46 GMT+0200 (Central European Summer Time)' is not valid for Start."]
__proto__: Object
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure response for https://dev-/api/medical/organisation/1/Participant/filter-by-registration?Filter=Invited&Start=Mon%20Oct%2007%202019%2012:58:46%20GMT%2B0200%20(Central%20European%20Summer%20Time): 400 Bad Request"
name: "HttpErrorResponse"
ok: false
status: 400
statusText: "Bad Request"
url: "/api/medical/organisation/1/Participant/filter-by-registration?Filter=Invited&Start=Mon%20Oct%2007%202019%2012:58:46%20GMT%2B0200%20(Central%20European%20Summer%20Time)"
__proto__: HttpResponseBase
Так что мой вопрос. как заполнить правильный формат даты на стороне клиента. Чтоб это не выкинуло ошибку?
Спасибо