[英]Angular 9 and ngx-admin nb Date picker invalid despite good format
我對https://akveo.github.io/nebular/docs/components/datepicker/overview#nbdatepickerdirective有疑問。 我有反應形式:
Component
this.addForm = new FormGroup({
'monthOfChangeStart': new FormControl(),
'monthOfChangeEnd': new FormControl(),
},
);
HTML template
<div class="form-group">
<label for="endDate">Month of Change End</label>
<input
nbInput
[nbDatepicker]="formControl"
aria-describedby=""
class="form-control"
[formControl]="addForm.get('monthOfChangeEnd')"
id="endDate"
type="text"
name="endDate"
>
<nb-datepicker
#formControl
format="dd-MM-yyyy" [formControl]="addForm.get('monthOfChangeEnd')"></nb-datepicker>
</div>
當我提供格式為 01-01-2020 的日期時,表格有效,但當我提供 13-01-2020 時,表格無效。 我認為 angular 認為 dd 是 MM 並因此將其聲明為無效。
有人有這個問題嗎?
根據Formatting Issue和Nebular部分,您可能忘記導入NbDateFnsDateModule或NbMomentDateModule 。 如果您選擇 akveo 建議
npm i @nebular/date-fns
你可能會得到像這里這樣的錯誤-> https://github.com/akveo/nebular/issues/2316所以只需安裝https://date-fns.org/docs/Getting-Started#installation 。 最后一個提示 - NbDateFnsDateModule或NbMomentDateModule應該在NbDatepickerModule之后導入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.