Run MarkDisabled function manually
See original GitHub issueBug description:
I don’t know if this is a bug or not.
Now when a month in a datepicker is rendered the [markDisabled]. So when you have 3 months which you display, you have 90~ days. 90 times the markDisabled is fired and this is OK.
But now when I select a date for example (in an already rendered datepicker) I want to disable some dates again. My first thought was that I can run a function on the datepicker #template like setDisabledOnDays, but there is not a kind of function like that.
As a work arround iIdid the trick below! To Reinitialize the disabled days.
private markDisabled() {
this.dpDate.navigateTo({
year: this.dpDate.months[0].year,
month: this.dpDate.months[0].number - 3
});
this.dpDate.navigateTo({
year: this.dpDate.months[0].year,
month: this.dpDate.months[0].number + 3
});
}
Idea to create a function to run the markDisabled again?
Link to minimally-working plunker that reproduces the issue:
You can fork a plunker from one of our demos and use it as a starting point. Please note that we can not act on bug reports without a minimal reproduction scenario in plunker. Here is why: https://github.com/ng-bootstrap/ng-bootstrap#you-think-youve-found-a-bug
Version of Angular, ng-bootstrap, and Bootstrap:
Angular: 2.3.5
ng-bootstrap: 20
Bootstrap: 6
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:5 (2 by maintainers)
Top GitHub Comments
@timmyrosen, a workaround might be to provide a new instance of the
markDisabled
function when you want the changes to be taken into account. Ugly, but should work.Here is the stackblitz: https://stackblitz.com/edit/angular-li9grd
@maxokorokov
This works when u set
[markDisabled]
to the<ngb-datepicker>
, but it does NOT work with the popup version (bindngbDatepicker
to an<input>
).I think it’s better to allow call markDisabled function manually. Or, can just make
[markDisabled]
function to be called eagerly (whenever user click any cells)