我正在尝试制作有角度的页面并使用打字稿,并且我正在使用日期选择器选择日期,后端方法正在等待参数为LocalDate
sendStartDateChangeEmail(updateData: { employeeId: number, selectedDate: string }) {
const requestParams = new HttpParams().append('requestedStartDate', updateData.selectedDate);
return this._http.post(`/request-start-date-change/` + updateData.employeeId, null, {params: requestParams})
.map((response: any) => {
if (response['success'] !== true) {
throw Observable.throw(response['errorMessage']);
}
return response;
});
}
如上所示,updateData.selectedDate是一个字符串,在后端方法中,日期接受为LocalDate而不是字符串。
public ResponseEntity<Boolean> sendStartDateChangeRequest(@PathVariable(name = "employeeId") long employeeId,
@RequestParam(name = "requestedStartDate") LocalDate requestedStartDate)
如何在前端将变量分配为LocalDate?