2

Max value in Mat ragepicker is not reflecting dynamically. I have replicated the same below. https://stackblitz.com/edit/angular-uc41kx-7a8m4h?file=src/app/date-range-picker-overview-example.html The below is what I have tried I wanted to limit the date selection to only 29 days. So when the date is changed the max value will be updated by startChange($event) function using (dateChange) event.

startChange(event: MatDatepickerInputEvent<Date>) {
    let maxDate;
    this.minDate = event.value;
    maxDate = moment(this.minDate).add(29, 'days').toDate();
    if (this.currentDate < maxDate) {
      this.currentDate =  moment().toDate() ;
    } else {
    this.currentDate = moment(this.minDate).add(29, 'days').toDate();
    }
  }

But with the above is not working,

Can anyone help me here.

Ebison J
  • 47
  • 1
  • 7
  • If you select an other date (03/06) for example, you want the range picker will be enabled until 06/25. Is it right? – Pterrat Mar 17 '22 at 09:02
  • Scenario1: if we select 01/Jan/2022 as from the date picker should set the to date as 30/Jan/2022. Scenario 2: Max value should not exceed current date eg: if we select 01/March/2022 as from, the date picket should set the to date 17/March/2022. – Ebison J Mar 17 '22 at 10:46

0 Answers0