New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date range limits in NgbDatepickerConfig can't be reset during runtime #4070
Comments
Your demo changes the config after the datepicker has been constructed. The datepicker reads the config values at construction time, but doesn't watch the configuration changes. If you call So, either make sure to avoid constructing he datepicker before its configuration is ready, or pass minDate and maxDate inputs to the datepicker directly. |
This is what I need, I want to change the configuration of the date picker and set the limits after constructing the date picker as the limits are not known until I got them from an API. So, is there any solution to perform this action after constructing the date picker? Also note that these limits (minDate - maxDate) are changed constantly during runtime depending on some user selections, so the component will be already initialized and the limits are changed. |
I think I already provided a solution above. Changing the config is only useful for datepickers created after the change, because the config is used to initialize the datepicker inputs. |
@jnizet Awesome, thanks a lot for your help! |
Bug description:
I am trying to make limits for date range during runtime depending on some dates that I will get from my project API. I am using NgbDatepickerConfig to set minDate and maxDate, although the configuration object is changed, the date picker still wasn't affected by these updates even if it is reflected with the changes of configurations that are in the component's constructor during initialization. I searched in the previous issues but I didn't get a working solution and the issue still exist.
Link to minimally-working StackBlitz that reproduces the issue:
Here is a demonstration link: StackBlitz
Versions of Angular, ng-bootstrap, and Bootstrap:
In my working project versions are:
Angular: 11.0.5
ng-bootstrap: 8.0.0
Bootstrap: 4.5.3
The text was updated successfully, but these errors were encountered: