ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

BsDatepicker config "keepDatesOutOfRules: true" only works with bsValue but not with ngModel or reactive forms

Open gehrmanng opened this issue 1 year ago • 2 comments

Bug description: When using BsDatepicker with a minDate, the configuration option "keepDatesOutOfRules: true" only works when the datepicker value is set by [bsValue]. When using Angular Forms [(ngModel)] or Angular Reactive Forms formControlName="..." instead, an invalid date value gets overwritten by the configured minDate.

Plunker/StackBlitz that reproduces the issue: Please find a working demo project here: https://github.com/gehrmanng/bs-datepicker-test and a StackBlitz here: https://stackblitz.com/edit/github-4ravqg

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 10.3.0 Angular: 15.2.0 Bootstrap: 5.2.3

Build system: Angular CLI / NPM

Expected behavior I would expect the datepicker to keep the invalid date value when the "keepDatesOutOfRules" option is set to true.

gehrmanng avatar Mar 24 '23 18:03 gehrmanng

Can we have the working example of the solution with reactive form in stackblitz?

VirendraMaheta7 avatar Oct 09 '23 11:10 VirendraMaheta7

Seeing the same problem. Cant use [(ngModel)] with keepDatesOutOfRules: true and minDate

here is a working stackblitz of the issue. https://stackblitz.com/~/github.com/rahul71/ngx-datepicker-demo @VirendraMaheta7 ^ @gehrmanng ^

Any help would be appreciated.

rahul71 avatar Jan 17 '24 22:01 rahul71