diff --git a/src/datepicker/datepicker-input.spec.ts b/src/datepicker/datepicker-input.spec.ts
index 0349dac15e..385959d49f 100644
--- a/src/datepicker/datepicker-input.spec.ts
+++ b/src/datepicker/datepicker-input.spec.ts
@@ -639,6 +639,62 @@ describe('NgbInputDatepicker', () => {
expect(dp.maxDate).toEqual({year: 2016, month: 9, day: 13});
});
+ it('should dynamically propagate the "minDate" option', () => {
+ const fixture = createTestCmpt(``);
+ const dpInput = fixture.debugElement.query(By.directive(NgbInputDatepicker)).injector.get(NgbInputDatepicker);
+ fixture.componentRef.instance.minDate = {year: 2018, month: 12, day: 31};
+
+ dpInput.open();
+ fixture.detectChanges();
+
+ const dp = fixture.debugElement.query(By.css('ngb-datepicker')).injector.get(NgbDatepicker);
+ expect(dp.minDate).toEqual({year: 2018, month: 12, day: 31});
+
+ fixture.componentRef.instance.minDate = {year: 2019, month: 11, day: 14};
+ fixture.detectChanges();
+ expect(dp.minDate).toEqual({year: 2019, month: 11, day: 14});
+
+ });
+
+ it('should dynamically propagate the "maxDate" option', () => {
+ const fixture = createTestCmpt(``);
+ const dpInput = fixture.debugElement.query(By.directive(NgbInputDatepicker)).injector.get(NgbInputDatepicker);
+ fixture.componentRef.instance.maxDate = {year: 2019, month: 12, day: 31};
+
+ dpInput.open();
+ fixture.detectChanges();
+
+ const dp = fixture.debugElement.query(By.css('ngb-datepicker')).injector.get(NgbDatepicker);
+ expect(dp.maxDate).toEqual({year: 2019, month: 12, day: 31});
+
+ fixture.componentRef.instance.maxDate = {year: 2019, month: 12, day: 14};
+ fixture.detectChanges();
+ expect(dp.maxDate).toEqual({year: 2019, month: 12, day: 14});
+
+ });
+
+ it('should dynamically propagate the "maxDate" and "minDate" option', () => {
+ const fixture = createTestCmpt(``);
+ const dpInput = fixture.debugElement.query(By.directive(NgbInputDatepicker)).injector.get(NgbInputDatepicker);
+ fixture.componentRef.instance.minDate = {year: 2019, month: 11, day: 14};
+ fixture.componentRef.instance.maxDate = {year: 2019, month: 12, day: 31};
+
+ dpInput.open();
+ fixture.detectChanges();
+
+ const dp = fixture.debugElement.query(By.css('ngb-datepicker')).injector.get(NgbDatepicker);
+ expect(dp.minDate).toEqual({year: 2019, month: 11, day: 14});
+ expect(dp.maxDate).toEqual({year: 2019, month: 12, day: 31});
+
+ fixture.componentRef.instance.minDate = {year: 2019, month: 10, day: 14};
+ fixture.componentRef.instance.maxDate = {year: 2019, month: 12, day: 14};
+ fixture.detectChanges();
+
+ expect(dp.minDate).toEqual({year: 2019, month: 10, day: 14});
+ expect(dp.maxDate).toEqual({year: 2019, month: 12, day: 14});
+
+ });
+
it('should propagate the "outsideDays" option', () => {
const fixture = createTestCmpt(``);
const dpInput = fixture.debugElement.query(By.directive(NgbInputDatepicker)).injector.get(NgbInputDatepicker);
@@ -1079,6 +1135,8 @@ class TestNativeComponent {
class TestComponent {
container;
date: NgbDateStruct;
+ minDate: NgbDateStruct;
+ maxDate: NgbDateStruct;
isDisabled;
onNavigate() {}
diff --git a/src/datepicker/datepicker-input.ts b/src/datepicker/datepicker-input.ts
index ca625b8236..108d77ebed 100644
--- a/src/datepicker/datepicker-input.ts
+++ b/src/datepicker/datepicker-input.ts
@@ -432,6 +432,16 @@ export class NgbInputDatepicker implements OnChanges,
ngOnChanges(changes: SimpleChanges) {
if (changes['minDate'] || changes['maxDate']) {
this._validatorChange();
+
+ if (this.isOpen()) {
+ if (changes['minDate']) {
+ this._cRef.instance.minDate = this._dateAdapter.toModel(changes.minDate.currentValue);
+ }
+ if (changes['maxDate']) {
+ this._cRef.instance.maxDate = this._dateAdapter.toModel(changes.maxDate.currentValue);
+ }
+ this._cRef.instance.ngOnChanges(changes);
+ }
}
}