0

我在我的 Angular 应用程序 v11 中使用 ng2-datepicker。

我第一次选择 2021 年 8 月 10 日的日期并且表格效果很好。当我尝试使用上述日期重置再次打开表单时,它会抛出底部错误。

<ngx-datepicker formControlName="modifiedAfter" [options]="options"></ngx-datepicker>

选项是:

this.options = {
  placeholder: 'dd/mm/yyyy',
  maxDate: this.maxDate,
  format: 'dd/mm/yyyy',
  position: 'bottom'
};

当表单值被重置时,它会抛出以下错误:

Unhandled error RangeError: Invalid time value
    at format (index.js:373)
    at DatepickerComponent.writeValue (ng2-datepicker.js:349)
    at setUpControl (forms.js:2397)
    at FormGroupDirective.addControl (forms.js:5626)
    at FormControlName._setUpControl (forms.js:6177)
    at FormControlName.ngOnChanges (forms.js:6122)
    at FormControlName.rememberChangeHistoryAndInvokeOnChangesHook (core.js:1471)
    at zone-patch-rxjs.js:108
    at Function.proto.<computed> (zone-evergreen.js:971)
    at callHook (core.js:2490)
log @ global-error-handler.service.ts:22
handleError @ global-error-handler.service.ts:12
(anonymous) @ core.js:29284
invoke @ zone-evergreen.js:368
run @ zone-evergreen.js:130
runOutsideAngular @ core.js:28229
tick @ core.js:29284
(anonymous) @ core.js:29156
invoke @ zone-evergreen.js:368
onInvoke @ core.js:28301
invoke @ zone-evergreen.js:367
run @ zone-evergreen.js:130
run @ core.js:28184
next @ core.js:29155
schedulerFn @ core.js:25666
(anonymous) @ zone-patch-rxjs.js:108
proto.<computed> @ zone-evergreen.js:971
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
rxjs.Subscriber.next @ zone-patch-rxjs.js:175
next @ Subject.js:39
emit @ core.js:25656
checkStable @ core.js:28237
onLeave @ core.js:28347
onInvokeTask @ core.js:28295
invokeTask @ zone-evergreen.js:401
runTask @ zone-evergreen.js:174
invokeTask @ zone-evergreen.js:483
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622
Show 2 more frames

谁能帮我解决这个问题?

4

0 回答 0